| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 11 #include "chrome/browser/extensions/test_management_policy.h" | 11 #include "chrome/browser/extensions/test_management_policy.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_commands.h" | 14 #include "chrome/browser/ui/browser_commands.h" |
| 15 #include "chrome/browser/ui/browser_finder.h" | 15 #include "chrome/browser/ui/browser_finder.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "content/public/test/test_utils.h" |
| 20 | 20 |
| 21 using extensions::Extension; | 21 using extensions::Extension; |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Find a browser other than |browser|. | 25 // Find a browser other than |browser|. |
| 26 Browser* FindOtherBrowser(Browser* browser) { | 26 Browser* FindOtherBrowser(Browser* browser) { |
| 27 Browser* found = NULL; | 27 Browser* found = NULL; |
| 28 for (BrowserList::const_iterator it = BrowserList::begin(); | 28 for (BrowserList::const_iterator it = BrowserList::begin(); |
| 29 it != BrowserList::end(); ++it) { | 29 it != BrowserList::end(); ++it) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 LoadAndWaitForLaunch("management/launch_app_panel", &app_id); | 145 LoadAndWaitForLaunch("management/launch_app_panel", &app_id); |
| 146 ASSERT_FALSE(HasFatalFailure()); // Stop the test if any ASSERT failed. | 146 ASSERT_FALSE(HasFatalFailure()); // Stop the test if any ASSERT failed. |
| 147 | 147 |
| 148 // Find the app's browser. Check that it is a panel. | 148 // Find the app's browser. Check that it is a panel. |
| 149 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); | 149 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); |
| 150 Browser* app_browser = FindOtherBrowser(browser()); | 150 Browser* app_browser = FindOtherBrowser(browser()); |
| 151 ASSERT_TRUE(app_browser->is_type_panel()); | 151 ASSERT_TRUE(app_browser->is_type_panel()); |
| 152 ASSERT_TRUE(app_browser->is_app()); | 152 ASSERT_TRUE(app_browser->is_app()); |
| 153 | 153 |
| 154 // Close the app panel. | 154 // Close the app panel. |
| 155 ui_test_utils::WindowedNotificationObserver signal( | 155 content::WindowedNotificationObserver signal( |
| 156 chrome::NOTIFICATION_BROWSER_CLOSED, | 156 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 157 content::Source<Browser>(app_browser)); | 157 content::Source<Browser>(app_browser)); |
| 158 | 158 |
| 159 chrome::CloseWindow(app_browser); | 159 chrome::CloseWindow(app_browser); |
| 160 signal.Wait(); | 160 signal.Wait(); |
| 161 | 161 |
| 162 // Unload the extension. | 162 // Unload the extension. |
| 163 UninstallExtension(app_id); | 163 UninstallExtension(app_id); |
| 164 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); | 164 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); |
| 165 ASSERT_FALSE(service->GetExtensionById(app_id, true)); | 165 ASSERT_FALSE(service->GetExtensionById(app_id, true)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 ASSERT_EQ(2, browser()->tab_count()); | 232 ASSERT_EQ(2, browser()->tab_count()); |
| 233 #else | 233 #else |
| 234 // Find the app's browser. Opening in a new window will create | 234 // Find the app's browser. Opening in a new window will create |
| 235 // a new browser. | 235 // a new browser. |
| 236 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); | 236 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); |
| 237 Browser* app_browser = FindOtherBrowser(browser()); | 237 Browser* app_browser = FindOtherBrowser(browser()); |
| 238 ASSERT_TRUE(app_browser->is_app()); | 238 ASSERT_TRUE(app_browser->is_app()); |
| 239 ASSERT_FALSE(app_browser->is_type_panel()); | 239 ASSERT_FALSE(app_browser->is_type_panel()); |
| 240 #endif | 240 #endif |
| 241 } | 241 } |
| OLD | NEW |