| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/automation/automation_util.h" | 12 #include "chrome/browser/automation/automation_util.h" |
| 13 #include "chrome/browser/extensions/extension_apitest.h" | 13 #include "chrome/browser/extensions/extension_apitest.h" |
| 14 #include "chrome/browser/extensions/extension_browsertest.h" | 14 #include "chrome/browser/extensions/extension_browsertest.h" |
| 15 #include "chrome/browser/extensions/extension_function_test_utils.h" | 15 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_system.h" |
| 17 #include "chrome/browser/extensions/extension_test_message_listener.h" | 18 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 18 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 19 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 19 #include "chrome/browser/extensions/shell_window_registry.h" | 20 #include "chrome/browser/extensions/shell_window_registry.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_commands.h" | 23 #include "chrome/browser/ui/browser_commands.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/browser/ui/extensions/application_launch.h" | 25 #include "chrome/browser/ui/extensions/application_launch.h" |
| 25 #include "chrome/browser/ui/extensions/shell_window.h" | 26 #include "chrome/browser/ui/extensions/shell_window.h" |
| 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 model_ = launcher_->model(); | 78 model_ = launcher_->model(); |
| 78 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); | 79 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 const Extension* LoadAndLaunchExtension( | 82 const Extension* LoadAndLaunchExtension( |
| 82 const char* name, | 83 const char* name, |
| 83 extension_misc::LaunchContainer container, | 84 extension_misc::LaunchContainer container, |
| 84 WindowOpenDisposition disposition) { | 85 WindowOpenDisposition disposition) { |
| 85 EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name))); | 86 EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name))); |
| 86 | 87 |
| 87 ExtensionService* service = browser()->profile()->GetExtensionService(); | 88 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 89 browser()->profile())->extension_service(); |
| 88 const Extension* extension = | 90 const Extension* extension = |
| 89 service->GetExtensionById(last_loaded_extension_id_, false); | 91 service->GetExtensionById(last_loaded_extension_id_, false); |
| 90 EXPECT_TRUE(extension); | 92 EXPECT_TRUE(extension); |
| 91 | 93 |
| 92 application_launch::OpenApplication(application_launch::LaunchParams( | 94 application_launch::OpenApplication(application_launch::LaunchParams( |
| 93 browser()->profile(), extension, container, disposition)); | 95 browser()->profile(), extension, container, disposition)); |
| 94 return extension; | 96 return extension; |
| 95 } | 97 } |
| 96 | 98 |
| 97 ash::LauncherID CreateShortcut(const char* name) { | 99 ash::LauncherID CreateShortcut(const char* name) { |
| 98 ExtensionService* service = browser()->profile()->GetExtensionService(); | 100 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 101 browser()->profile())->extension_service(); |
| 99 LoadExtension(test_data_dir_.AppendASCII(name)); | 102 LoadExtension(test_data_dir_.AppendASCII(name)); |
| 100 | 103 |
| 101 // First get app_id. | 104 // First get app_id. |
| 102 const Extension* extension = | 105 const Extension* extension = |
| 103 service->GetExtensionById(last_loaded_extension_id_, false); | 106 service->GetExtensionById(last_loaded_extension_id_, false); |
| 104 const std::string app_id = extension->id(); | 107 const std::string app_id = extension->id(); |
| 105 | 108 |
| 106 // Then create a shortcut. | 109 // Then create a shortcut. |
| 107 ChromeLauncherController* controller = | 110 ChromeLauncherController* controller = |
| 108 static_cast<ChromeLauncherController*>(launcher_->delegate()); | 111 static_cast<ChromeLauncherController*>(launcher_->delegate()); |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 734 |
| 732 // Activating app should launch new tab, because second tab isn't | 735 // Activating app should launch new tab, because second tab isn't |
| 733 // in its refocus url path. | 736 // in its refocus url path. |
| 734 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 737 launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
| 735 EXPECT_EQ(++tab_count, tab_strip->count()); | 738 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 736 TabContents* second_tab = tab_strip->GetActiveTabContents(); | 739 TabContents* second_tab = tab_strip->GetActiveTabContents(); |
| 737 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); | 740 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status); |
| 738 EXPECT_NE(first_tab, second_tab); | 741 EXPECT_NE(first_tab, second_tab); |
| 739 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); | 742 EXPECT_EQ(tab_strip->GetActiveTabContents(), second_tab); |
| 740 } | 743 } |
| OLD | NEW |