OLD | NEW |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 // Tests switching rapidly between multiple pages of the launcher. | 105 // Tests switching rapidly between multiple pages of the launcher. |
106 void RunPageSwitchingAnimationTest(); | 106 void RunPageSwitchingAnimationTest(); |
107 | 107 |
108 // Tests changing the App List profile. | 108 // Tests changing the App List profile. |
109 void RunProfileChangeTest(); | 109 void RunProfileChangeTest(); |
110 | 110 |
111 // Tests displaying of the search results. | 111 // Tests displaying of the search results. |
112 void RunSearchResultsTest(); | 112 void RunSearchResultsTest(); |
113 | 113 |
| 114 // Tests displaying the app list overlay. |
| 115 void RunAppListOverlayTest(); |
| 116 |
114 // A standard set of checks on a view, e.g., ensuring it is drawn and visible. | 117 // A standard set of checks on a view, e.g., ensuring it is drawn and visible. |
115 static void CheckView(views::View* subview); | 118 static void CheckView(views::View* subview); |
116 | 119 |
117 // Invoked when the Widget is closing, and the view it contains is about to | 120 // Invoked when the Widget is closing, and the view it contains is about to |
118 // be torn down. This only occurs in a run loop and will be used as a signal | 121 // be torn down. This only occurs in a run loop and will be used as a signal |
119 // to quit. | 122 // to quit. |
120 void NativeWidgetClosing() { | 123 void NativeWidgetClosing() { |
121 view_ = NULL; | 124 view_ = NULL; |
122 run_loop_->Quit(); | 125 run_loop_->Quit(); |
123 } | 126 } |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 main_view->search_box_view()->search_box()->text()); | 662 main_view->search_box_view()->search_box()->text()); |
660 contents_view->Layout(); | 663 contents_view->Layout(); |
661 EXPECT_TRUE(IsStateShown(AppListModel::STATE_SEARCH_RESULTS)); | 664 EXPECT_TRUE(IsStateShown(AppListModel::STATE_SEARCH_RESULTS)); |
662 EXPECT_TRUE( | 665 EXPECT_TRUE( |
663 CheckSearchBoxWidget(contents_view->GetDefaultSearchBoxBounds())); | 666 CheckSearchBoxWidget(contents_view->GetDefaultSearchBoxBounds())); |
664 } | 667 } |
665 | 668 |
666 Close(); | 669 Close(); |
667 } | 670 } |
668 | 671 |
| 672 void AppListViewTestContext::RunAppListOverlayTest() { |
| 673 Show(); |
| 674 |
| 675 AppListMainView* main_view = view_->app_list_main_view(); |
| 676 SearchBoxView* search_box_view = main_view->search_box_view(); |
| 677 |
| 678 // The search box should not be enabled when the app list overlay is shown. |
| 679 view_->SetAppListOverlayVisible(true); |
| 680 EXPECT_FALSE(search_box_view->enabled()); |
| 681 |
| 682 // The search box should be refocused when the app list overlay is hidden. |
| 683 view_->SetAppListOverlayVisible(false); |
| 684 EXPECT_TRUE(search_box_view->enabled()); |
| 685 EXPECT_EQ(search_box_view->search_box(), |
| 686 view_->GetWidget()->GetFocusManager()->GetFocusedView()); |
| 687 |
| 688 Close(); |
| 689 } |
| 690 |
669 class AppListViewTestAura : public views::ViewsTestBase, | 691 class AppListViewTestAura : public views::ViewsTestBase, |
670 public ::testing::WithParamInterface<int> { | 692 public ::testing::WithParamInterface<int> { |
671 public: | 693 public: |
672 AppListViewTestAura() {} | 694 AppListViewTestAura() {} |
673 virtual ~AppListViewTestAura() {} | 695 virtual ~AppListViewTestAura() {} |
674 | 696 |
675 // testing::Test overrides: | 697 // testing::Test overrides: |
676 void SetUp() override { | 698 void SetUp() override { |
677 views::ViewsTestBase::SetUp(); | 699 views::ViewsTestBase::SetUp(); |
678 | 700 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 | 840 |
819 // Tests that the back button navigates through the app list correctly. | 841 // Tests that the back button navigates through the app list correctly. |
820 TEST_P(AppListViewTestAura, BackTest) { | 842 TEST_P(AppListViewTestAura, BackTest) { |
821 EXPECT_NO_FATAL_FAILURE(test_context_->RunBackTest()); | 843 EXPECT_NO_FATAL_FAILURE(test_context_->RunBackTest()); |
822 } | 844 } |
823 | 845 |
824 TEST_P(AppListViewTestDesktop, BackTest) { | 846 TEST_P(AppListViewTestDesktop, BackTest) { |
825 EXPECT_NO_FATAL_FAILURE(test_context_->RunBackTest()); | 847 EXPECT_NO_FATAL_FAILURE(test_context_->RunBackTest()); |
826 } | 848 } |
827 | 849 |
| 850 // Tests that the correct views are displayed for showing search results. |
| 851 TEST_P(AppListViewTestAura, AppListOverlayTest) { |
| 852 EXPECT_NO_FATAL_FAILURE(test_context_->RunAppListOverlayTest()); |
| 853 } |
| 854 |
| 855 TEST_P(AppListViewTestDesktop, AppListOverlayTest) { |
| 856 EXPECT_NO_FATAL_FAILURE(test_context_->RunAppListOverlayTest()); |
| 857 } |
| 858 |
828 #if defined(USE_AURA) | 859 #if defined(USE_AURA) |
829 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 860 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
830 AppListViewTestAura, | 861 AppListViewTestAura, |
831 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 862 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
832 #endif | 863 #endif |
833 | 864 |
834 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 865 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
835 AppListViewTestDesktop, | 866 AppListViewTestDesktop, |
836 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 867 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
837 | 868 |
838 } // namespace test | 869 } // namespace test |
839 } // namespace app_list | 870 } // namespace app_list |
OLD | NEW |