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

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

Issue 2878133002: mash: Serialize ShelfIDs for property conversion and transport. (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 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 EXPECT_FALSE(window_state->IsMinimized()); 2159 EXPECT_FALSE(window_state->IsMinimized());
2160 } 2160 }
2161 2161
2162 // Check that the window's ShelfID property matches that of the active tab. 2162 // Check that the window's ShelfID property matches that of the active tab.
2163 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) { 2163 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) {
2164 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 2164 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
2165 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 2165 EXPECT_EQ(1, browser()->tab_strip_model()->count());
2166 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 2166 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
2167 EXPECT_EQ(2, model_->item_count()); 2167 EXPECT_EQ(2, model_->item_count());
2168 2168
2169 ash::WmWindow* window = 2169 aura::Window* window = browser()->window()->GetNativeWindow();
2170 ash::WmWindow::Get(browser()->window()->GetNativeWindow());
2171 2170
2172 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); 2171 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT);
2173 ash::ShelfID browser_id = model_->items()[browser_index].id; 2172 ash::ShelfID browser_id = model_->items()[browser_index].id;
2174 ash::ShelfID* id = window->aura_window()->GetProperty(ash::kShelfIDKey); 2173 ash::ShelfID id =
2175 ASSERT_NE(nullptr, id); 2174 ash::ShelfID::Deserialize(window->GetProperty(ash::kShelfIDKey));
2176 EXPECT_EQ(browser_id, *id); 2175 EXPECT_EQ(browser_id, id);
2177 2176
2178 ash::ShelfID app_id = CreateShortcut("app1"); 2177 ash::ShelfID app_id = CreateShortcut("app1");
2179 EXPECT_EQ(3, model_->item_count()); 2178 EXPECT_EQ(3, model_->item_count());
2180 2179
2181 // Create and activate a new tab for "app1" and expect an application ShelfID. 2180 // Create and activate a new tab for "app1" and expect an application ShelfID.
2182 WmShelf::ActivateShelfItem(model_->ItemIndexByID(app_id)); 2181 WmShelf::ActivateShelfItem(model_->ItemIndexByID(app_id));
2183 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 2182 EXPECT_EQ(2, browser()->tab_strip_model()->count());
2184 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 2183 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
2185 id = window->aura_window()->GetProperty(ash::kShelfIDKey); 2184 id = ash::ShelfID::Deserialize(window->GetProperty(ash::kShelfIDKey));
2186 ASSERT_NE(nullptr, id); 2185 EXPECT_EQ(app_id, id);
2187 EXPECT_EQ(app_id, *id);
2188 2186
2189 // Activate the tab at index 0 (NTP) and expect a browser ShelfID. 2187 // Activate the tab at index 0 (NTP) and expect a browser ShelfID.
2190 browser()->tab_strip_model()->ActivateTabAt(0, false); 2188 browser()->tab_strip_model()->ActivateTabAt(0, false);
2191 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 2189 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
2192 id = window->aura_window()->GetProperty(ash::kShelfIDKey); 2190 id = ash::ShelfID::Deserialize(window->GetProperty(ash::kShelfIDKey));
2193 ASSERT_NE(nullptr, id); 2191 EXPECT_EQ(browser_id, id);
2194 EXPECT_EQ(browser_id, *id);
2195 } 2192 }
2196 2193
2197 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) { 2194 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) {
2198 // Make sure to have a browser window 2195 // Make sure to have a browser window
2199 chrome::NewTab(browser()); 2196 chrome::NewTab(browser());
2200 2197
2201 // No overflow yet. 2198 // No overflow yet.
2202 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble()); 2199 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble());
2203 2200
2204 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting()); 2201 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting());
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 2404
2408 // Close all windows via the menu item. 2405 // Close all windows via the menu item.
2409 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2406 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2410 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2407 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2411 2408
2412 // Check if "Close" is removed from the context menu. 2409 // Check if "Close" is removed from the context menu.
2413 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); 2410 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu();
2414 ASSERT_FALSE( 2411 ASSERT_FALSE(
2415 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2412 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2416 } 2413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698