1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/task_manager/task_manager.h"
8 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_dialogs.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "extensions/common/switches.h"
13 #include "extensions/test/extension_test_message_listener.h"
15 // Test is flaky: http://crbug.com/346990
16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest
, DISABLED_Processes
) {
17 ASSERT_TRUE(RunExtensionTest("processes/api")) << message_
;
20 IN_PROC_BROWSER_TEST_F(ExtensionApiTest
, ProcessesVsTaskManager
) {
21 // This test is for the old implementation of the task manager. We must
22 // explicitly disable the new one.
23 task_manager::browsertest_util::EnableOldTaskManager();
25 // Ensure task manager is not yet updating
26 TaskManagerModel
* model
= TaskManager::GetInstance()->model();
27 EXPECT_EQ(0, model
->update_requests_
);
28 EXPECT_EQ(TaskManagerModel::IDLE
, model
->update_state_
);
30 // Load extension that adds listener in background page
31 ExtensionTestMessageListener
listener("ready", false);
32 ASSERT_TRUE(LoadExtension(
33 test_data_dir_
.AppendASCII("processes").AppendASCII("onupdated")));
34 ASSERT_TRUE(listener
.WaitUntilSatisfied());
36 // Ensure the task manager has started updating
37 EXPECT_EQ(1, model
->update_requests_
);
38 EXPECT_EQ(TaskManagerModel::TASK_PENDING
, model
->update_state_
);
40 // Now show the task manager and wait for it to be ready
41 chrome::ShowTaskManager(browser());
43 EXPECT_EQ(2, model
->update_requests_
);
44 EXPECT_EQ(TaskManagerModel::TASK_PENDING
, model
->update_state_
);
46 // Unload the extension and check that listener count decreases
47 UnloadExtension(last_loaded_extension_id());
48 EXPECT_EQ(1, model
->update_requests_
);