• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
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"
14 
15 // Test is flaky: http://crbug.com/346990
IN_PROC_BROWSER_TEST_F(ExtensionApiTest,DISABLED_Processes)16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Processes) {
17   ASSERT_TRUE(RunExtensionTest("processes/api")) << message_;
18 }
19 
IN_PROC_BROWSER_TEST_F(ExtensionApiTest,ProcessesVsTaskManager)20 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ProcessesVsTaskManager) {
21   // Ensure task manager is not yet updating
22   TaskManagerModel* model = TaskManager::GetInstance()->model();
23   EXPECT_EQ(0, model->update_requests_);
24   EXPECT_EQ(TaskManagerModel::IDLE, model->update_state_);
25 
26   // Load extension that adds listener in background page
27   ExtensionTestMessageListener listener("ready", false);
28   ASSERT_TRUE(LoadExtension(
29       test_data_dir_.AppendASCII("processes").AppendASCII("onupdated")));
30   ASSERT_TRUE(listener.WaitUntilSatisfied());
31 
32   // Ensure the task manager has started updating
33   EXPECT_EQ(1, model->update_requests_);
34   EXPECT_EQ(TaskManagerModel::TASK_PENDING, model->update_state_);
35 
36   // Now show the task manager and wait for it to be ready
37   chrome::ShowTaskManager(browser());
38 
39   EXPECT_EQ(2, model->update_requests_);
40   EXPECT_EQ(TaskManagerModel::TASK_PENDING, model->update_state_);
41 
42   // Unload the extension and check that listener count decreases
43   UnloadExtension(last_loaded_extension_id());
44   EXPECT_EQ(1, model->update_requests_);
45 }
46