Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc

Issue 2870683002: ash: Remove ShelfModel id conversion functions. (Closed)
Patch Set: Address comments. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/public/cpp/shelf_item_delegate.h" 9 #include "ash/public/cpp/shelf_item_delegate.h"
10 #include "ash/public/cpp/window_properties.h" 10 #include "ash/public/cpp/window_properties.h"
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 params.window_type = AppWindow::WINDOW_TYPE_PANEL; 1528 params.window_type = AppWindow::WINDOW_TYPE_PANEL;
1529 params.focused = false; 1529 params.focused = false;
1530 AppWindow* panel = 1530 AppWindow* panel =
1531 CreateAppWindowFromParams(browser()->profile(), extension, params); 1531 CreateAppWindowFromParams(browser()->profile(), extension, params);
1532 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); 1532 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
1533 // Panels should not be active by default. 1533 // Panels should not be active by default.
1534 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); 1534 EXPECT_FALSE(panel->GetBaseWindow()->IsActive());
1535 // Confirm that a shelf item was created and is the correct state. 1535 // Confirm that a shelf item was created and is the correct state.
1536 const ash::ShelfItem& item = GetLastLauncherPanelItem(); 1536 const ash::ShelfItem& item = GetLastLauncherPanelItem();
1537 ash::ShelfItemDelegate* shelf_item_delegate = GetShelfItemDelegate(item.id); 1537 ash::ShelfItemDelegate* shelf_item_delegate = GetShelfItemDelegate(item.id);
1538 EXPECT_NE(nullptr, shelf_item_delegate); 1538 EXPECT_TRUE(shelf_item_delegate);
1539 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); 1539 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type);
1540 EXPECT_EQ(ash::STATUS_RUNNING, item.status); 1540 EXPECT_EQ(ash::STATUS_RUNNING, item.status);
1541 1541
1542 // App windows should go to attention state. 1542 // App windows should go to attention state.
1543 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); 1543 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true);
1544 EXPECT_EQ(ash::STATUS_ATTENTION, item.status); 1544 EXPECT_EQ(ash::STATUS_ATTENTION, item.status);
1545 1545
1546 // Click the item and confirm that the panel is activated. 1546 // Click the item and confirm that the panel is activated.
1547 EXPECT_EQ(ash::SHELF_ACTION_WINDOW_ACTIVATED, 1547 EXPECT_EQ(ash::SHELF_ACTION_WINDOW_ACTIVATED,
1548 SelectItem(shelf_item_delegate, ui::ET_MOUSE_PRESSED)); 1548 SelectItem(shelf_item_delegate, ui::ET_MOUSE_PRESSED));
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 2221
2222 test.RunMessageLoopUntilAnimationsDone(); 2222 test.RunMessageLoopUntilAnimationsDone();
2223 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble()); 2223 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble());
2224 } 2224 }
2225 2225
2226 // Check that a windowed V1 application can navigate away from its domain, but 2226 // Check that a windowed V1 application can navigate away from its domain, but
2227 // still gets detected properly. 2227 // still gets detected properly.
2228 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, V1AppNavigation) { 2228 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, V1AppNavigation) {
2229 // We assume that the web store is always there (which it apparently is). 2229 // We assume that the web store is always there (which it apparently is).
2230 controller_->PinAppWithID(extensions::kWebStoreAppId); 2230 controller_->PinAppWithID(extensions::kWebStoreAppId);
2231 ash::ShelfID id = controller_->GetShelfIDForAppID(extensions::kWebStoreAppId); 2231 const ash::ShelfID id(extensions::kWebStoreAppId);
2232 EXPECT_FALSE(id.IsNull());
2233 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); 2232 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status);
2234 2233
2235 // Create a windowed application. 2234 // Create a windowed application.
2236 AppLaunchParams params = CreateAppLaunchParamsUserContainer( 2235 AppLaunchParams params = CreateAppLaunchParamsUserContainer(
2237 profile(), GetExtensionForAppID(extensions::kWebStoreAppId, profile()), 2236 profile(), GetExtensionForAppID(extensions::kWebStoreAppId, profile()),
2238 WindowOpenDisposition::NEW_FOREGROUND_TAB, extensions::SOURCE_TEST); 2237 WindowOpenDisposition::NEW_FOREGROUND_TAB, extensions::SOURCE_TEST);
2239 params.container = extensions::LAUNCH_CONTAINER_WINDOW; 2238 params.container = extensions::LAUNCH_CONTAINER_WINDOW;
2240 OpenApplication(params); 2239 OpenApplication(params);
2241 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status); 2240 EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(id)->status);
2242 2241
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 // crbug.com/230464. 2299 // crbug.com/230464.
2301 } 2300 }
2302 2301
2303 // Check that tabbed hosted and bookmark apps have correct shelf presence. 2302 // Check that tabbed hosted and bookmark apps have correct shelf presence.
2304 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, TabbedHostedAndBookmarkApps) { 2303 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, TabbedHostedAndBookmarkApps) {
2305 // Load and pin a hosted app. 2304 // Load and pin a hosted app.
2306 const Extension* hosted_app = 2305 const Extension* hosted_app =
2307 LoadExtension(test_data_dir_.AppendASCII("app1/")); 2306 LoadExtension(test_data_dir_.AppendASCII("app1/"));
2308 ASSERT_TRUE(hosted_app); 2307 ASSERT_TRUE(hosted_app);
2309 controller_->PinAppWithID(hosted_app->id()); 2308 controller_->PinAppWithID(hosted_app->id());
2310 const ash::ShelfID hosted_app_shelf_id = 2309 const ash::ShelfID hosted_app_shelf_id(hosted_app->id());
2311 controller_->GetShelfIDForAppID(hosted_app->id());
2312 2310
2313 // Load and pin a bookmark app. 2311 // Load and pin a bookmark app.
2314 const Extension* bookmark_app = InstallExtensionWithSourceAndFlags( 2312 const Extension* bookmark_app = InstallExtensionWithSourceAndFlags(
2315 test_data_dir_.AppendASCII("app2/"), 1, extensions::Manifest::INTERNAL, 2313 test_data_dir_.AppendASCII("app2/"), 1, extensions::Manifest::INTERNAL,
2316 extensions::Extension::FROM_BOOKMARK); 2314 extensions::Extension::FROM_BOOKMARK);
2317 ASSERT_TRUE(bookmark_app); 2315 ASSERT_TRUE(bookmark_app);
2318 controller_->PinAppWithID(bookmark_app->id()); 2316 controller_->PinAppWithID(bookmark_app->id());
2319 const ash::ShelfID bookmark_app_shelf_id = 2317 const ash::ShelfID bookmark_app_shelf_id(bookmark_app->id());
2320 controller_->GetShelfIDForAppID(bookmark_app->id());
2321 2318
2322 // The apps should be closed. 2319 // The apps should be closed.
2323 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status); 2320 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status);
2324 EXPECT_EQ(ash::STATUS_CLOSED, 2321 EXPECT_EQ(ash::STATUS_CLOSED,
2325 model_->ItemByID(bookmark_app_shelf_id)->status); 2322 model_->ItemByID(bookmark_app_shelf_id)->status);
2326 2323
2327 // Navigate to the app's launch URLs in two tabs. 2324 // Navigate to the app's launch URLs in two tabs.
2328 ui_test_utils::NavigateToURL( 2325 ui_test_utils::NavigateToURL(
2329 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(hosted_app)); 2326 browser(), extensions::AppLaunchInfo::GetLaunchWebURL(hosted_app));
2330 ui_test_utils::NavigateToURLWithDisposition( 2327 ui_test_utils::NavigateToURLWithDisposition(
(...skipping 14 matching lines...) Expand all
2345 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 2342 EXPECT_EQ(2, browser()->tab_strip_model()->count());
2346 } 2343 }
2347 2344
2348 // Check that windowed hosted and bookmark apps have correct shelf presence. 2345 // Check that windowed hosted and bookmark apps have correct shelf presence.
2349 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, WindowedHostedAndBookmarkApps) { 2346 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, WindowedHostedAndBookmarkApps) {
2350 // Load and pin a hosted app. 2347 // Load and pin a hosted app.
2351 const Extension* hosted_app = 2348 const Extension* hosted_app =
2352 LoadExtension(test_data_dir_.AppendASCII("app1/")); 2349 LoadExtension(test_data_dir_.AppendASCII("app1/"));
2353 ASSERT_TRUE(hosted_app); 2350 ASSERT_TRUE(hosted_app);
2354 controller_->PinAppWithID(hosted_app->id()); 2351 controller_->PinAppWithID(hosted_app->id());
2355 const ash::ShelfID hosted_app_shelf_id = 2352 const ash::ShelfID hosted_app_shelf_id(hosted_app->id());
2356 controller_->GetShelfIDForAppID(hosted_app->id());
2357 2353
2358 // Load and pin a bookmark app. 2354 // Load and pin a bookmark app.
2359 const Extension* bookmark_app = InstallExtensionWithSourceAndFlags( 2355 const Extension* bookmark_app = InstallExtensionWithSourceAndFlags(
2360 test_data_dir_.AppendASCII("app2/"), 1, extensions::Manifest::INTERNAL, 2356 test_data_dir_.AppendASCII("app2/"), 1, extensions::Manifest::INTERNAL,
2361 extensions::Extension::FROM_BOOKMARK); 2357 extensions::Extension::FROM_BOOKMARK);
2362 ASSERT_TRUE(bookmark_app); 2358 ASSERT_TRUE(bookmark_app);
2363 controller_->PinAppWithID(bookmark_app->id()); 2359 controller_->PinAppWithID(bookmark_app->id());
2364 const ash::ShelfID bookmark_app_shelf_id = 2360 const ash::ShelfID bookmark_app_shelf_id(bookmark_app->id());
2365 controller_->GetShelfIDForAppID(bookmark_app->id());
2366 2361
2367 // Set both apps to open in windows. 2362 // Set both apps to open in windows.
2368 extensions::SetLaunchType(browser()->profile(), hosted_app->id(), 2363 extensions::SetLaunchType(browser()->profile(), hosted_app->id(),
2369 extensions::LAUNCH_TYPE_WINDOW); 2364 extensions::LAUNCH_TYPE_WINDOW);
2370 extensions::SetLaunchType(browser()->profile(), bookmark_app->id(), 2365 extensions::SetLaunchType(browser()->profile(), bookmark_app->id(),
2371 extensions::LAUNCH_TYPE_WINDOW); 2366 extensions::LAUNCH_TYPE_WINDOW);
2372 2367
2373 // The apps should be closed. 2368 // The apps should be closed.
2374 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status); 2369 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(hosted_app_shelf_id)->status);
2375 EXPECT_EQ(ash::STATUS_CLOSED, 2370 EXPECT_EQ(ash::STATUS_CLOSED,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 2407
2413 // Close all windows via the menu item. 2408 // Close all windows via the menu item.
2414 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2409 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2415 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2410 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2416 2411
2417 // Check if "Close" is removed from the context menu. 2412 // Check if "Close" is removed from the context menu.
2418 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); 2413 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu();
2419 ASSERT_FALSE( 2414 ASSERT_FALSE(
2420 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2415 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2421 } 2416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698