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

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

Issue 701773002: App list: Added contents view custom animation framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename some arguments. Created 6 years, 1 month 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 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/app_list/app_list_switches.h" 12 #include "ui/app_list/app_list_switches.h"
13 #include "ui/app_list/pagination_model.h" 13 #include "ui/app_list/pagination_model.h"
14 #include "ui/app_list/search_box_model.h" 14 #include "ui/app_list/search_box_model.h"
15 #include "ui/app_list/test/app_list_test_model.h" 15 #include "ui/app_list/test/app_list_test_model.h"
16 #include "ui/app_list/test/app_list_test_view_delegate.h" 16 #include "ui/app_list/test/app_list_test_view_delegate.h"
17 #include "ui/app_list/test/test_search_result.h" 17 #include "ui/app_list/test/test_search_result.h"
18 #include "ui/app_list/views/app_list_folder_view.h" 18 #include "ui/app_list/views/app_list_folder_view.h"
19 #include "ui/app_list/views/app_list_main_view.h" 19 #include "ui/app_list/views/app_list_main_view.h"
20 #include "ui/app_list/views/apps_container_view.h" 20 #include "ui/app_list/views/apps_container_view.h"
21 #include "ui/app_list/views/apps_grid_view.h" 21 #include "ui/app_list/views/apps_grid_view.h"
22 #include "ui/app_list/views/contents_animator.h"
22 #include "ui/app_list/views/contents_switcher_view.h" 23 #include "ui/app_list/views/contents_switcher_view.h"
23 #include "ui/app_list/views/contents_view.h" 24 #include "ui/app_list/views/contents_view.h"
24 #include "ui/app_list/views/search_box_view.h" 25 #include "ui/app_list/views/search_box_view.h"
25 #include "ui/app_list/views/search_result_list_view.h" 26 #include "ui/app_list/views/search_result_list_view.h"
26 #include "ui/app_list/views/search_result_tile_item_view.h" 27 #include "ui/app_list/views/search_result_tile_item_view.h"
27 #include "ui/app_list/views/start_page_view.h" 28 #include "ui/app_list/views/start_page_view.h"
28 #include "ui/app_list/views/test/apps_grid_view_test_api.h" 29 #include "ui/app_list/views/test/apps_grid_view_test_api.h"
29 #include "ui/app_list/views/tile_item_view.h" 30 #include "ui/app_list/views/tile_item_view.h"
30 #include "ui/views/controls/textfield/textfield.h" 31 #include "ui/views/controls/textfield/textfield.h"
31 #include "ui/views/test/views_test_base.h" 32 #include "ui/views/test/views_test_base.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Hides and reshows the app list with a folder open, expecting the main grid 96 // Hides and reshows the app list with a folder open, expecting the main grid
96 // view to be shown. 97 // view to be shown.
97 void RunReshowWithOpenFolderTest(); 98 void RunReshowWithOpenFolderTest();
98 99
99 // Tests displaying of the experimental app list and shows the start page. 100 // Tests displaying of the experimental app list and shows the start page.
100 void RunStartPageTest(); 101 void RunStartPageTest();
101 102
102 // Tests switching rapidly between multiple pages of the launcher. 103 // Tests switching rapidly between multiple pages of the launcher.
103 void RunPageSwitchingAnimationTest(); 104 void RunPageSwitchingAnimationTest();
104 105
106 // Tests custom animations between different pages of the launcher.
107 void RunCustomAnimationsTest();
108
105 // Tests changing the App List profile. 109 // Tests changing the App List profile.
106 void RunProfileChangeTest(); 110 void RunProfileChangeTest();
107 111
108 // Tests displaying of the search results. 112 // Tests displaying of the search results.
109 void RunSearchResultsTest(); 113 void RunSearchResultsTest();
110 114
111 // A standard set of checks on a view, e.g., ensuring it is drawn and visible. 115 // A standard set of checks on a view, e.g., ensuring it is drawn and visible.
112 static void CheckView(views::View* subview); 116 static void CheckView(views::View* subview);
113 117
114 // Invoked when the Widget is closing, and the view it contains is about to 118 // Invoked when the Widget is closing, and the view it contains is about to
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Call Layout(). Should jump to the third page. 439 // Call Layout(). Should jump to the third page.
436 contents_view->Layout(); 440 contents_view->Layout();
437 EXPECT_NE(expected_bounds, contents_view->GetPageView(0)->bounds()); 441 EXPECT_NE(expected_bounds, contents_view->GetPageView(0)->bounds());
438 EXPECT_NE(expected_bounds, contents_view->GetPageView(1)->bounds()); 442 EXPECT_NE(expected_bounds, contents_view->GetPageView(1)->bounds());
439 EXPECT_EQ(expected_bounds, contents_view->GetPageView(2)->bounds()); 443 EXPECT_EQ(expected_bounds, contents_view->GetPageView(2)->bounds());
440 } 444 }
441 445
442 Close(); 446 Close();
443 } 447 }
444 448
449 void AppListViewTestContext::RunCustomAnimationsTest() {
450 if (test_type_ == EXPERIMENTAL) {
451 Show();
452
453 ContentsView* contents_view = view_->app_list_main_view()->contents_view();
454 ContentsAnimator* animator;
455 bool reverse;
456
457 // A transition without a custom animation.
458 animator = contents_view->GetAnimatorForTransitionForTests(
459 contents_view->GetPageIndexForState(AppListModel::STATE_START),
460 contents_view->GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS),
461 &reverse);
462 EXPECT_EQ("DefaultAnimator", animator->NameForTests());
463 EXPECT_FALSE(reverse);
464
465 // Test some custom animations.
466 animator = contents_view->GetAnimatorForTransitionForTests(
467 contents_view->GetPageIndexForState(AppListModel::STATE_START),
468 contents_view->GetPageIndexForState(AppListModel::STATE_APPS),
469 &reverse);
470 EXPECT_EQ("StartToAppsAnimator", animator->NameForTests());
471 EXPECT_FALSE(reverse);
472
473 animator = contents_view->GetAnimatorForTransitionForTests(
474 contents_view->GetPageIndexForState(AppListModel::STATE_APPS),
475 contents_view->GetPageIndexForState(AppListModel::STATE_START),
476 &reverse);
477 EXPECT_EQ("StartToAppsAnimator", animator->NameForTests());
478 EXPECT_TRUE(reverse);
479 }
480
481 Close();
calamity 2014/11/05 06:29:07 It's probably worth putting this in its own conten
Matt Giuca 2014/11/06 00:32:58 I just tried doing this. It basically requires the
calamity 2014/11/06 05:34:47 ??? Why? AppListMainViewTest gets by without an Ap
Matt Giuca 2014/11/10 04:08:26 Done. (Thanks for the tip; it was non-obvious how
482 }
483
445 void AppListViewTestContext::RunProfileChangeTest() { 484 void AppListViewTestContext::RunProfileChangeTest() {
446 EXPECT_FALSE(view_->GetWidget()->IsVisible()); 485 EXPECT_FALSE(view_->GetWidget()->IsVisible());
447 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); 486 EXPECT_EQ(-1, GetPaginationModel()->total_pages());
448 delegate_->GetTestModel()->PopulateApps(kInitialItems); 487 delegate_->GetTestModel()->PopulateApps(kInitialItems);
449 488
450 Show(); 489 Show();
451 490
452 if (is_landscape()) 491 if (is_landscape())
453 EXPECT_EQ(2, GetPaginationModel()->total_pages()); 492 EXPECT_EQ(2, GetPaginationModel()->total_pages());
454 else 493 else
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 755
717 // Tests that the start page view operates correctly. 756 // Tests that the start page view operates correctly.
718 TEST_P(AppListViewTestAura, PageSwitchingAnimationTest) { 757 TEST_P(AppListViewTestAura, PageSwitchingAnimationTest) {
719 EXPECT_NO_FATAL_FAILURE(test_context_->RunPageSwitchingAnimationTest()); 758 EXPECT_NO_FATAL_FAILURE(test_context_->RunPageSwitchingAnimationTest());
720 } 759 }
721 760
722 TEST_P(AppListViewTestDesktop, PageSwitchingAnimationTest) { 761 TEST_P(AppListViewTestDesktop, PageSwitchingAnimationTest) {
723 EXPECT_NO_FATAL_FAILURE(test_context_->RunPageSwitchingAnimationTest()); 762 EXPECT_NO_FATAL_FAILURE(test_context_->RunPageSwitchingAnimationTest());
724 } 763 }
725 764
765 // Tests that the contents view correctly selects custom animations.
766 TEST_P(AppListViewTestAura, CustomAnimationsTest) {
767 EXPECT_NO_FATAL_FAILURE(test_context_->RunCustomAnimationsTest());
768 }
769
770 TEST_P(AppListViewTestDesktop, CustomAnimationsTest) {
771 EXPECT_NO_FATAL_FAILURE(test_context_->RunCustomAnimationsTest());
772 }
773
726 // Tests that the profile changes operate correctly. 774 // Tests that the profile changes operate correctly.
727 TEST_P(AppListViewTestAura, ProfileChangeTest) { 775 TEST_P(AppListViewTestAura, ProfileChangeTest) {
728 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); 776 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest());
729 } 777 }
730 778
731 TEST_P(AppListViewTestDesktop, ProfileChangeTest) { 779 TEST_P(AppListViewTestDesktop, ProfileChangeTest) {
732 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); 780 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest());
733 } 781 }
734 782
735 // Tests that the correct views are displayed for showing search results. 783 // Tests that the correct views are displayed for showing search results.
736 TEST_P(AppListViewTestAura, SearchResultsTest) { 784 TEST_P(AppListViewTestAura, SearchResultsTest) {
737 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest()); 785 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest());
738 } 786 }
739 787
740 TEST_P(AppListViewTestDesktop, SearchResultsTest) { 788 TEST_P(AppListViewTestDesktop, SearchResultsTest) {
741 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest()); 789 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest());
742 } 790 }
743 791
744 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, 792 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance,
745 AppListViewTestAura, 793 AppListViewTestAura,
746 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); 794 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END));
747 795
748 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, 796 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance,
749 AppListViewTestDesktop, 797 AppListViewTestDesktop,
750 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); 798 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END));
751 799
752 } // namespace test 800 } // namespace test
753 } // namespace app_list 801 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698