Chromium Code Reviews| 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 } | |
|
stevenjb
2015/07/09 19:41:09
ASSERT_TRUE(app_browser);
oshima
2015/07/09 20:14:04
ASSERT_TRUE is for the precondition that will othe
| |
| 1318 aura::Window* window = app_browser->window()->GetNativeWindow(); | |
| 1319 EXPECT_FALSE(ash::wm::GetWindowState(window)->IsMaximized()); | |
| 1320 ash::wm::GetWindowState(window)->Maximize(); | |
| 1321 EXPECT_TRUE(ash::wm::GetWindowState(window)->IsMaximized()); | |
| 1322 app_browser->window()->Close(); | |
|
stevenjb
2015/07/09 19:41:09
test that the window is closed here.
xdai1
2015/07/09 22:46:46
Done.
| |
| 1323 | |
| 1324 // Reopen it. | |
| 1325 extension = LoadAndLaunchExtension( | |
| 1326 "app1", extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW); | |
| 1327 app_browser = nullptr; | |
| 1328 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | |
| 1329 std::string browser_app_id = | |
| 1330 web_app::GetExtensionIdFromApplicationName((*it)->app_name()); | |
| 1331 if (browser_app_id == extension->id()) { | |
| 1332 app_browser = *it; | |
| 1333 break; | |
| 1334 } | |
| 1335 } | |
|
stevenjb
2015/07/09 19:41:09
Put the above code into a helper function in an an
xdai1
2015/07/09 22:46:46
Done.
| |
| 1336 window = app_browser->window()->GetNativeWindow(); | |
| 1337 EXPECT_TRUE(ash::wm::GetWindowState(window)->IsMaximized()); | |
|
stevenjb
2015/07/09 19:41:09
For completeness we should un-maximize the window,
xdai1
2015/07/09 22:46:46
Done.
| |
| 1338 } | |
| 1339 | |
| 1302 // Checks that a windowed application does not add an item to the browser list. | 1340 // Checks that a windowed application does not add an item to the browser list. |
| 1303 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, | 1341 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
| 1304 WindowedAppDoesNotAddToBrowser) { | 1342 WindowedAppDoesNotAddToBrowser) { |
| 1305 // Get the number of items in the browser menu. | 1343 // Get the number of items in the browser menu. |
| 1306 size_t items = NumberOfDetectedLauncherBrowsers(false); | 1344 size_t items = NumberOfDetectedLauncherBrowsers(false); |
| 1307 size_t running_browser = chrome::GetTotalBrowserCount(); | 1345 size_t running_browser = chrome::GetTotalBrowserCount(); |
| 1308 EXPECT_EQ(0u, items); | 1346 EXPECT_EQ(0u, items); |
| 1309 EXPECT_EQ(0u, running_browser); | 1347 EXPECT_EQ(0u, running_browser); |
| 1310 | 1348 |
| 1311 LoadAndLaunchExtension( | 1349 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); | 2307 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
| 2270 | 2308 |
| 2271 // There should be two new browsers. | 2309 // There should be two new browsers. |
| 2272 EXPECT_EQ(3u, chrome::GetTotalBrowserCountForProfile(browser()->profile())); | 2310 EXPECT_EQ(3u, chrome::GetTotalBrowserCountForProfile(browser()->profile())); |
| 2273 | 2311 |
| 2274 // The apps should now be running, with the last opened app active. | 2312 // 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); | 2313 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); |
| 2276 EXPECT_EQ(ash::STATUS_ACTIVE, | 2314 EXPECT_EQ(ash::STATUS_ACTIVE, |
| 2277 model_->ItemByID(bookmark_app_shelf_id)->status); | 2315 model_->ItemByID(bookmark_app_shelf_id)->status); |
| 2278 } | 2316 } |
| OLD | NEW |