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

Side by Side Diff: ui/app_list/views/app_list_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_unittest.cc ('k') | ui/app_list/views/contents_view.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_view.h" 5 #include "ui/app_list/views/app_list_view.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 void AppListViewTestContext::CheckView(views::View* subview) { 227 void AppListViewTestContext::CheckView(views::View* subview) {
228 ASSERT_TRUE(subview); 228 ASSERT_TRUE(subview);
229 EXPECT_TRUE(subview->parent()); 229 EXPECT_TRUE(subview->parent());
230 EXPECT_TRUE(subview->visible()); 230 EXPECT_TRUE(subview->visible());
231 EXPECT_TRUE(subview->IsDrawn()); 231 EXPECT_TRUE(subview->IsDrawn());
232 EXPECT_FALSE(subview->bounds().IsEmpty()); 232 EXPECT_FALSE(subview->bounds().IsEmpty());
233 } 233 }
234 234
235 bool AppListViewTestContext::SetAppListState(AppListModel::State state) { 235 bool AppListViewTestContext::SetAppListState(AppListModel::State state) {
236 ContentsView* contents_view = view_->app_list_main_view()->contents_view(); 236 ContentsView* contents_view = view_->app_list_main_view()->contents_view();
237 int index = contents_view->GetPageIndexForState(state); 237 contents_view->SetActiveState(state);
238 contents_view->SetActivePage(index);
239 contents_view->Layout(); 238 contents_view->Layout();
240 return IsStateShown(state); 239 return IsStateShown(state);
241 } 240 }
242 241
243 bool AppListViewTestContext::IsStateShown(AppListModel::State state) { 242 bool AppListViewTestContext::IsStateShown(AppListModel::State state) {
244 ContentsView* contents_view = view_->app_list_main_view()->contents_view(); 243 ContentsView* contents_view = view_->app_list_main_view()->contents_view();
245 int index = contents_view->GetPageIndexForState(state); 244 int index = contents_view->GetPageIndexForState(state);
246 bool success = true; 245 bool success = true;
247 for (int i = 0; i < contents_view->NumLauncherPages(); ++i) { 246 for (int i = 0; i < contents_view->NumLauncherPages(); ++i) {
248 success = success && 247 success = success &&
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 void AppListViewTestContext::RunPageSwitchingAnimationTest() { 501 void AppListViewTestContext::RunPageSwitchingAnimationTest() {
503 if (test_type_ == EXPERIMENTAL) { 502 if (test_type_ == EXPERIMENTAL) {
504 Show(); 503 Show();
505 504
506 AppListMainView* main_view = view_->app_list_main_view(); 505 AppListMainView* main_view = view_->app_list_main_view();
507 // Checks on the main view. 506 // Checks on the main view.
508 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); 507 EXPECT_NO_FATAL_FAILURE(CheckView(main_view));
509 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); 508 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view()));
510 509
511 ContentsView* contents_view = main_view->contents_view(); 510 ContentsView* contents_view = main_view->contents_view();
512 // Pad the ContentsView with blank pages so we have at least 3 views.
513 while (contents_view->NumLauncherPages() < 3)
514 contents_view->AddBlankPageForTesting();
515 511
516 contents_view->SetActivePage(0); 512 int start_page_index =
513 contents_view->GetPageIndexForState(AppListModel::STATE_START);
514 int search_results_page_index =
515 contents_view->GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS);
516 int apps_page_index =
517 contents_view->GetPageIndexForState(AppListModel::STATE_APPS);
518
519 contents_view->SetActiveState(AppListModel::STATE_START);
517 contents_view->Layout(); 520 contents_view->Layout();
518 521
519 EXPECT_EQ(contents_view->GetOnscreenPageBounds(0), 522 EXPECT_EQ(contents_view->GetOnscreenPageBounds(start_page_index),
520 contents_view->GetPageView(0)->bounds()); 523 contents_view->GetPageView(start_page_index)->bounds());
521 EXPECT_NE(contents_view->GetOnscreenPageBounds(1), 524 EXPECT_NE(contents_view->GetOnscreenPageBounds(search_results_page_index),
522 contents_view->GetPageView(1)->bounds()); 525 contents_view->GetPageView(search_results_page_index)->bounds());
523 EXPECT_NE(contents_view->GetOnscreenPageBounds(2), 526 EXPECT_NE(contents_view->GetOnscreenPageBounds(apps_page_index),
524 contents_view->GetPageView(2)->bounds()); 527 contents_view->GetPageView(apps_page_index)->bounds());
525 528
526 // Change pages. View should not have moved without Layout(). 529 // Change pages. View should not have moved without Layout().
527 contents_view->SetActivePage(1); 530 contents_view->SetActiveState(AppListModel::STATE_SEARCH_RESULTS);
528 EXPECT_EQ(contents_view->GetOnscreenPageBounds(0), 531 EXPECT_EQ(contents_view->GetOnscreenPageBounds(start_page_index),
529 contents_view->GetPageView(0)->bounds()); 532 contents_view->GetPageView(start_page_index)->bounds());
530 EXPECT_NE(contents_view->GetOnscreenPageBounds(1), 533 EXPECT_NE(contents_view->GetOnscreenPageBounds(search_results_page_index),
531 contents_view->GetPageView(1)->bounds()); 534 contents_view->GetPageView(search_results_page_index)->bounds());
532 EXPECT_NE(contents_view->GetOnscreenPageBounds(2), 535 EXPECT_NE(contents_view->GetOnscreenPageBounds(apps_page_index),
533 contents_view->GetPageView(2)->bounds()); 536 contents_view->GetPageView(apps_page_index)->bounds());
534 537
535 // Change to a third page. This queues up the second animation behind the 538 // Change to a third page. This queues up the second animation behind the
536 // first. 539 // first.
537 contents_view->SetActivePage(2); 540 contents_view->SetActiveState(AppListModel::STATE_APPS);
538 EXPECT_EQ(contents_view->GetOnscreenPageBounds(0), 541 EXPECT_EQ(contents_view->GetOnscreenPageBounds(start_page_index),
539 contents_view->GetPageView(0)->bounds()); 542 contents_view->GetPageView(start_page_index)->bounds());
540 EXPECT_NE(contents_view->GetOnscreenPageBounds(1), 543 EXPECT_NE(contents_view->GetOnscreenPageBounds(search_results_page_index),
541 contents_view->GetPageView(1)->bounds()); 544 contents_view->GetPageView(search_results_page_index)->bounds());
542 EXPECT_NE(contents_view->GetOnscreenPageBounds(2), 545 EXPECT_NE(contents_view->GetOnscreenPageBounds(apps_page_index),
543 contents_view->GetPageView(2)->bounds()); 546 contents_view->GetPageView(apps_page_index)->bounds());
544 547
545 // Call Layout(). Should jump to the third page. 548 // Call Layout(). Should jump to the third page.
546 contents_view->Layout(); 549 contents_view->Layout();
547 EXPECT_NE(contents_view->GetOnscreenPageBounds(0), 550 EXPECT_NE(contents_view->GetOnscreenPageBounds(start_page_index),
548 contents_view->GetPageView(0)->bounds()); 551 contents_view->GetPageView(start_page_index)->bounds());
549 EXPECT_NE(contents_view->GetOnscreenPageBounds(1), 552 EXPECT_NE(contents_view->GetOnscreenPageBounds(search_results_page_index),
550 contents_view->GetPageView(1)->bounds()); 553 contents_view->GetPageView(search_results_page_index)->bounds());
551 EXPECT_EQ(contents_view->GetOnscreenPageBounds(2), 554 EXPECT_EQ(contents_view->GetOnscreenPageBounds(apps_page_index),
552 contents_view->GetPageView(2)->bounds()); 555 contents_view->GetPageView(apps_page_index)->bounds());
553 } 556 }
554 557
555 Close(); 558 Close();
556 } 559 }
557 560
558 void AppListViewTestContext::RunProfileChangeTest() { 561 void AppListViewTestContext::RunProfileChangeTest() {
559 EXPECT_FALSE(view_->GetWidget()->IsVisible()); 562 EXPECT_FALSE(view_->GetWidget()->IsVisible());
560 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); 563 EXPECT_EQ(-1, GetPaginationModel()->total_pages());
561 delegate_->GetTestModel()->PopulateApps(kInitialItems); 564 delegate_->GetTestModel()->PopulateApps(kInitialItems);
562 565
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 AppListViewTestAura, 864 AppListViewTestAura,
862 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); 865 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END));
863 #endif 866 #endif
864 867
865 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, 868 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance,
866 AppListViewTestDesktop, 869 AppListViewTestDesktop,
867 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); 870 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END));
868 871
869 } // namespace test 872 } // namespace test
870 } // namespace app_list 873 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_main_view_unittest.cc ('k') | ui/app_list/views/contents_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698