OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
10 #include "ash/shelf/shelf_button.h" | 10 #include "ash/shelf/shelf_button.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "chrome/browser/extensions/extension_service.h" | 29 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/extensions/launch_util.h" | 30 #include "chrome/browser/extensions/launch_util.h" |
31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/ui/app_list/app_list_service.h" | 32 #include "chrome/browser/ui/app_list/app_list_service.h" |
33 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" | 33 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" |
34 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 34 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
35 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 35 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
36 #include "chrome/browser/ui/browser.h" | 36 #include "chrome/browser/ui/browser.h" |
37 #include "chrome/browser/ui/browser_commands.h" | 37 #include "chrome/browser/ui/browser_commands.h" |
38 #include "chrome/browser/ui/browser_finder.h" | 38 #include "chrome/browser/ui/browser_finder.h" |
39 #include "chrome/browser/ui/browser_iterator.h" | |
39 #include "chrome/browser/ui/browser_list.h" | 40 #include "chrome/browser/ui/browser_list.h" |
40 #include "chrome/browser/ui/browser_window.h" | 41 #include "chrome/browser/ui/browser_window.h" |
41 #include "chrome/browser/ui/chrome_pages.h" | 42 #include "chrome/browser/ui/chrome_pages.h" |
42 #include "chrome/browser/ui/extensions/app_launch_params.h" | 43 #include "chrome/browser/ui/extensions/app_launch_params.h" |
43 #include "chrome/browser/ui/extensions/application_launch.h" | 44 #include "chrome/browser/ui/extensions/application_launch.h" |
44 #include "chrome/browser/ui/host_desktop.h" | 45 #include "chrome/browser/ui/host_desktop.h" |
45 #include "chrome/browser/ui/settings_window_manager.h" | 46 #include "chrome/browser/ui/settings_window_manager.h" |
46 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 47 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
48 #include "chrome/browser/web_applications/web_app.h" | |
47 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
48 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 50 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
49 #include "chrome/test/base/ui_test_utils.h" | 51 #include "chrome/test/base/ui_test_utils.h" |
50 #include "content/public/browser/notification_service.h" | 52 #include "content/public/browser/notification_service.h" |
51 #include "content/public/browser/notification_source.h" | 53 #include "content/public/browser/notification_source.h" |
52 #include "content/public/browser/web_contents.h" | 54 #include "content/public/browser/web_contents.h" |
53 #include "content/public/test/browser_test_utils.h" | 55 #include "content/public/test/browser_test_utils.h" |
54 #include "extensions/browser/app_window/app_window.h" | 56 #include "extensions/browser/app_window/app_window.h" |
55 #include "extensions/browser/app_window/app_window_registry.h" | 57 #include "extensions/browser/app_window/app_window_registry.h" |
56 #include "extensions/browser/app_window/native_app_window.h" | 58 #include "extensions/browser/app_window/native_app_window.h" |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1292 // has to be active. | 1294 // has to be active. |
1293 tab_strip->ActivateTabAt(1, false); | 1295 tab_strip->ActivateTabAt(1, false); |
1294 EXPECT_EQ(1, tab_strip->active_index()); | 1296 EXPECT_EQ(1, tab_strip->active_index()); |
1295 | 1297 |
1296 // Close the web contents. | 1298 // Close the web contents. |
1297 tab_strip->CloseWebContentsAt(1, TabStripModel::CLOSE_NONE); | 1299 tab_strip->CloseWebContentsAt(1, TabStripModel::CLOSE_NONE); |
1298 // The status should now be set to closed. | 1300 // The status should now be set to closed. |
1299 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); | 1301 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status); |
1300 } | 1302 } |
1301 | 1303 |
1304 // Test that the App window could restore to its previous window state from | |
1305 // before it was closed. | |
1306 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, AppWindowRestoreBehaviorTest) { | |
1307 const Extension* extension = LoadAndLaunchExtension( | |
1308 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); | |
1309 Browser* app_browser = nullptr; | |
1310 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | |
1311 std::string browser_app_id = | |
1312 web_app::GetExtensionIdFromApplicationName((*it)->app_name()); | |
1313 if (browser_app_id == extension->id()) { | |
1314 app_browser = *it; | |
1315 break; | |
1316 } | |
1317 } | |
1318 DCHECK(app_browser); | |
oshima
2015/07/09 18:59:28
you don't need DCHECK because it'll fail in next l
stevenjb
2015/07/09 19:42:24
In general, never use DCHECK in tests, because it
| |
1319 aura::Window* window = app_browser->window()->GetNativeWindow(); | |
1320 EXPECT_FALSE(ash::wm::GetWindowState(window)->IsMaximized()); | |
1321 ash::wm::GetWindowState(window)->Maximize(); | |
1322 EXPECT_TRUE(ash::wm::GetWindowState(window)->IsMaximized()); | |
1323 app_browser->window()->Close(); | |
1324 | |
1325 // Reopen it. | |
1326 extension = LoadAndLaunchExtension( | |
1327 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); | |
1328 app_browser = nullptr; | |
1329 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | |
1330 std::string browser_app_id = | |
1331 web_app::GetExtensionIdFromApplicationName((*it)->app_name()); | |
1332 if (browser_app_id == extension->id()) { | |
1333 app_browser = *it; | |
1334 break; | |
1335 } | |
1336 } | |
1337 DCHECK(app_browser); | |
oshima
2015/07/09 18:59:28
ditto
| |
1338 window = app_browser->window()->GetNativeWindow(); | |
1339 EXPECT_TRUE(ash::wm::GetWindowState(window)->IsMaximized()); | |
1340 } | |
1341 | |
1302 // Checks that a windowed application does not add an item to the browser list. | 1342 // Checks that a windowed application does not add an item to the browser list. |
1303 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, | 1343 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
1304 WindowedAppDoesNotAddToBrowser) { | 1344 WindowedAppDoesNotAddToBrowser) { |
1305 // Get the number of items in the browser menu. | 1345 // Get the number of items in the browser menu. |
1306 size_t items = NumberOfDetectedLauncherBrowsers(false); | 1346 size_t items = NumberOfDetectedLauncherBrowsers(false); |
1307 size_t running_browser = chrome::GetTotalBrowserCount(); | 1347 size_t running_browser = chrome::GetTotalBrowserCount(); |
1308 EXPECT_EQ(0u, items); | 1348 EXPECT_EQ(0u, items); |
1309 EXPECT_EQ(0u, running_browser); | 1349 EXPECT_EQ(0u, running_browser); |
1310 | 1350 |
1311 LoadAndLaunchExtension( | 1351 LoadAndLaunchExtension( |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2269 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2309 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
2270 | 2310 |
2271 // There should be two new browsers. | 2311 // There should be two new browsers. |
2272 EXPECT_EQ(3u, chrome::GetTotalBrowserCountForProfile(browser()->profile())); | 2312 EXPECT_EQ(3u, chrome::GetTotalBrowserCountForProfile(browser()->profile())); |
2273 | 2313 |
2274 // The apps should now be running, with the last opened app active. | 2314 // The apps should now be running, with the last opened app active. |
2275 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); | 2315 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); |
2276 EXPECT_EQ(ash::STATUS_ACTIVE, | 2316 EXPECT_EQ(ash::STATUS_ACTIVE, |
2277 model_->ItemByID(bookmark_app_shelf_id)->status); | 2317 model_->ItemByID(bookmark_app_shelf_id)->status); |
2278 } | 2318 } |
OLD | NEW |