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

Side by Side Diff: ui/app_list/views/app_list_main_view_unittest.cc

Issue 947903002: Change ContentsView::SetActivePage to use States rather than indexes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more_rebase Created 5 years, 9 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
« no previous file with comments | « ui/app_list/views/app_list_main_view.cc ('k') | ui/app_list/views/app_list_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/app_list/views/app_list_main_view.h" 5 #include "ui/app_list/views/app_list_main_view.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 delegate_->GetTestModel()->PopulateApps(2); 271 delegate_->GetTestModel()->PopulateApps(2);
272 main_widget_->Show(); 272 main_widget_->Show();
273 273
274 ui::test::EventGenerator generator(GetContext(), 274 ui::test::EventGenerator generator(GetContext(),
275 main_widget_->GetNativeWindow()); 275 main_widget_->GetNativeWindow());
276 AppListItemView* item0 = RootViewModel()->view_at(0); 276 AppListItemView* item0 = RootViewModel()->view_at(0);
277 AppListItemView* item1 = RootViewModel()->view_at(1); 277 AppListItemView* item1 = RootViewModel()->view_at(1);
278 278
279 // If experimental launcher, switch to All Apps page 279 // If experimental launcher, switch to All Apps page
280 if (app_list::switches::IsExperimentalAppListEnabled()) { 280 if (app_list::switches::IsExperimentalAppListEnabled()) {
281 GetContentsView()->SetActivePage( 281 GetContentsView()->SetActiveState(AppListModel::STATE_APPS);
282 GetContentsView()->GetPageIndexForState(AppListModel::STATE_APPS));
283 GetContentsView()->Layout(); 282 GetContentsView()->Layout();
284 } 283 }
285 284
286 generator.MoveMouseTo(item0->GetBoundsInScreen().CenterPoint()); 285 generator.MoveMouseTo(item0->GetBoundsInScreen().CenterPoint());
287 EXPECT_TRUE(item0->is_highlighted()); 286 EXPECT_TRUE(item0->is_highlighted());
288 EXPECT_FALSE(item1->is_highlighted()); 287 EXPECT_FALSE(item1->is_highlighted());
289 288
290 generator.MoveMouseTo(item1->GetBoundsInScreen().CenterPoint()); 289 generator.MoveMouseTo(item1->GetBoundsInScreen().CenterPoint());
291 EXPECT_FALSE(item0->is_highlighted()); 290 EXPECT_FALSE(item0->is_highlighted());
292 EXPECT_TRUE(item1->is_highlighted()); 291 EXPECT_TRUE(item1->is_highlighted());
(...skipping 14 matching lines...) Expand all
307 TEST_F(AppListMainViewTest, MAYBE_TapGestureToHighlight) { 306 TEST_F(AppListMainViewTest, MAYBE_TapGestureToHighlight) {
308 delegate_->GetTestModel()->PopulateApps(1); 307 delegate_->GetTestModel()->PopulateApps(1);
309 main_widget_->Show(); 308 main_widget_->Show();
310 309
311 ui::test::EventGenerator generator(GetContext(), 310 ui::test::EventGenerator generator(GetContext(),
312 main_widget_->GetNativeWindow()); 311 main_widget_->GetNativeWindow());
313 AppListItemView* item = RootViewModel()->view_at(0); 312 AppListItemView* item = RootViewModel()->view_at(0);
314 313
315 // If experimental launcher, switch to All Apps page 314 // If experimental launcher, switch to All Apps page
316 if (app_list::switches::IsExperimentalAppListEnabled()) { 315 if (app_list::switches::IsExperimentalAppListEnabled()) {
317 GetContentsView()->SetActivePage( 316 GetContentsView()->SetActiveState(AppListModel::STATE_APPS);
318 GetContentsView()->GetPageIndexForState(AppListModel::STATE_APPS));
319 GetContentsView()->Layout(); 317 GetContentsView()->Layout();
320 } 318 }
321 319
322 generator.set_current_location(item->GetBoundsInScreen().CenterPoint()); 320 generator.set_current_location(item->GetBoundsInScreen().CenterPoint());
323 generator.PressTouch(); 321 generator.PressTouch();
324 EXPECT_TRUE(item->is_highlighted()); 322 EXPECT_TRUE(item->is_highlighted());
325 323
326 generator.ReleaseTouch(); 324 generator.ReleaseTouch();
327 EXPECT_FALSE(item->is_highlighted()); 325 EXPECT_FALSE(item->is_highlighted());
328 } 326 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 362
365 // Tests dragging an item out of a single item folder and dropping it onto the 363 // Tests dragging an item out of a single item folder and dropping it onto the
366 // page switcher. Regression test for http://crbug.com/415530/. 364 // page switcher. Regression test for http://crbug.com/415530/.
367 TEST_F(AppListMainViewTest, DragReparentItemOntoPageSwitcher) { 365 TEST_F(AppListMainViewTest, DragReparentItemOntoPageSwitcher) {
368 // Number of apps to populate. Should provide more than 1 page of apps (6*4 = 366 // Number of apps to populate. Should provide more than 1 page of apps (6*4 =
369 // 24). 367 // 24).
370 const int kNumApps = 30; 368 const int kNumApps = 30;
371 369
372 // Ensure we are on the apps grid view page. 370 // Ensure we are on the apps grid view page.
373 app_list::ContentsView* contents_view = GetContentsView(); 371 app_list::ContentsView* contents_view = GetContentsView();
374 contents_view->SetActivePage( 372 contents_view->SetActiveState(AppListModel::STATE_APPS);
375 contents_view->GetPageIndexForState(AppListModel::STATE_APPS));
376 contents_view->Layout(); 373 contents_view->Layout();
377 374
378 AppListItemView* folder_item_view = CreateAndOpenSingleItemFolder(); 375 AppListItemView* folder_item_view = CreateAndOpenSingleItemFolder();
379 const gfx::Rect first_slot_tile = folder_item_view->bounds(); 376 const gfx::Rect first_slot_tile = folder_item_view->bounds();
380 377
381 delegate_->GetTestModel()->PopulateApps(kNumApps); 378 delegate_->GetTestModel()->PopulateApps(kNumApps);
382 379
383 EXPECT_EQ(1, FolderViewModel()->view_size()); 380 EXPECT_EQ(1, FolderViewModel()->view_size());
384 EXPECT_EQ(kNumApps + 1, RootViewModel()->view_size()); 381 EXPECT_EQ(kNumApps + 1, RootViewModel()->view_size());
385 382
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // The app list model should remain unchanged. 446 // The app list model should remain unchanged.
450 EXPECT_EQ(1, FolderViewModel()->view_size()); 447 EXPECT_EQ(1, FolderViewModel()->view_size());
451 EXPECT_EQ(2, RootViewModel()->view_size()); 448 EXPECT_EQ(2, RootViewModel()->view_size());
452 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); 449 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id());
453 EXPECT_NE(nullptr, 450 EXPECT_NE(nullptr,
454 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); 451 delegate_->GetTestModel()->FindFolderItem("single_item_folder"));
455 } 452 }
456 453
457 } // namespace test 454 } // namespace test
458 } // namespace app_list 455 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_main_view.cc ('k') | ui/app_list/views/app_list_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698