Chromium Code Reviews| Index: ui/app_list/views/app_list_view_unittest.cc |
| diff --git a/ui/app_list/views/app_list_view_unittest.cc b/ui/app_list/views/app_list_view_unittest.cc |
| index a6dd89365268d4385410b08f9e2d81e8d147b0b7..f7d566e1fda45d52b68e6c69327395c8da6eb569 100644 |
| --- a/ui/app_list/views/app_list_view_unittest.cc |
| +++ b/ui/app_list/views/app_list_view_unittest.cc |
| @@ -18,6 +18,7 @@ |
| #include "ui/app_list/views/apps_grid_view.h" |
| #include "ui/app_list/views/contents_view.h" |
| #include "ui/app_list/views/search_box_view.h" |
| +#include "ui/app_list/views/start_page_view.h" |
| #include "ui/app_list/views/test/apps_grid_view_test_api.h" |
| #include "ui/aura/test/aura_test_base.h" |
| #include "ui/aura/window.h" |
| @@ -30,6 +31,14 @@ namespace test { |
| namespace { |
| +enum TestType { |
| + TEST_TYPE_START = 0, |
| + NORMAL = TEST_TYPE_START, |
| + LANDSCAPE, |
| + EXPERIMENTAL, |
| + TEST_TYPE_END, |
| +}; |
| + |
| // Choose a set that is 3 regular app list pages and 2 landscape app list pages. |
| const int kInitialItems = 34; |
| @@ -37,7 +46,7 @@ const int kInitialItems = 34; |
| // root window or a desktop window tree host. |
| class AppListViewTestContext { |
| public: |
| - AppListViewTestContext(bool is_landscape, aura::Window* parent); |
| + AppListViewTestContext(int test_type, aura::Window* parent); |
| ~AppListViewTestContext(); |
| // Test displaying the app list and performs a standard set of checks on its |
| @@ -48,6 +57,9 @@ class AppListViewTestContext { |
| // view to be shown. |
| void RunReshowWithOpenFolderTest(); |
| + // Tests displaying of the experimental app list and shows the start page. |
| + void RunStartPageTest(); |
| + |
| // A standard set of checks on a view, e.g., ensuring it is drawn and visible. |
| static void CheckView(views::View* subview); |
| @@ -60,7 +72,9 @@ class AppListViewTestContext { |
| } |
| // Whether the experimental "landscape" app launcher UI is being tested. |
| - bool is_landscape() const { return is_landscape_; } |
| + bool is_landscape() const { |
| + return test_type_ == LANDSCAPE || test_type_ == EXPERIMENTAL; |
| + } |
| private: |
| // Shows the app list and waits until a paint occurs. |
| @@ -69,7 +83,7 @@ class AppListViewTestContext { |
| // Closes the app list. This sets |view_| to NULL. |
| void Close(); |
| - const bool is_landscape_; |
| + const TestType test_type_; |
| scoped_ptr<base::RunLoop> run_loop_; |
| PaginationModel pagination_model_; |
| app_list::AppListView* view_; // Owned by native widget. |
| @@ -99,12 +113,23 @@ class UnitTestViewDelegate : public app_list::test::AppListTestViewDelegate { |
| DISALLOW_COPY_AND_ASSIGN(UnitTestViewDelegate); |
| }; |
| -AppListViewTestContext::AppListViewTestContext(bool is_landscape, |
| +AppListViewTestContext::AppListViewTestContext(int test_type, |
| aura::Window* parent) |
| - : is_landscape_(is_landscape) { |
| - if (is_landscape_) { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - switches::kEnableCenteredAppList); |
| + : test_type_(static_cast<TestType>(test_type)) { |
| + switch (test_type_) { |
| + case NORMAL: |
| + break; |
| + case LANDSCAPE: |
| + base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| + switches::kEnableCenteredAppList); |
| + break; |
| + case EXPERIMENTAL: |
| + base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| + switches::kEnableExperimentalAppList); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + break; |
| } |
| delegate_ = new UnitTestViewDelegate(this); |
| @@ -157,7 +182,7 @@ void AppListViewTestContext::RunDisplayTest() { |
| delegate_->GetTestModel()->PopulateApps(kInitialItems); |
| Show(); |
| - if (is_landscape_) |
| + if (is_landscape()) |
| EXPECT_EQ(2, pagination_model_.total_pages()); |
| else |
| EXPECT_EQ(3, pagination_model_.total_pages()); |
| @@ -216,8 +241,33 @@ void AppListViewTestContext::RunReshowWithOpenFolderTest() { |
| Close(); |
| } |
| +void AppListViewTestContext::RunStartPageTest() { |
| + if (test_type_ != EXPERIMENTAL) |
|
tapted
2014/05/22 05:01:27
Can it still PopulateApps, and we just check the s
calamity
2014/05/23 04:10:23
Done.
|
| + return; |
| + |
| + EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
| + EXPECT_EQ(-1, pagination_model_.total_pages()); |
| + delegate_->GetTestModel()->PopulateApps(kInitialItems); |
| + |
|
tapted
2014/05/22 05:01:27
EXPECT_EQ(2, pagination_model_.total_pages()); ?
calamity
2014/05/23 04:10:23
Is this worth rechecking given that it's already c
|
| + Show(); |
| + |
| + // Checks on the main view. |
| + AppListMainView* main_view = view_->app_list_main_view(); |
| + EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
| + EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); |
| + EXPECT_NO_FATAL_FAILURE( |
| + CheckView(main_view->contents_view()->start_page_view())); |
| + |
| + main_view->contents_view()->SetShowState(ContentsView::SHOW_START_PAGE); |
| + EXPECT_FALSE(main_view->search_box_view()->visible()); |
| + main_view->contents_view()->SetShowState(ContentsView::SHOW_APPS); |
| + EXPECT_TRUE(main_view->search_box_view()->visible()); |
| + |
|
tapted
2014/05/22 05:01:27
EXPECT_FALSE(main_view->contents_view()->start_pag
calamity
2014/05/23 04:10:23
Yeahhhhhh it's just offscreen. =(
Made it check t
|
| + Close(); |
| +} |
| + |
| class AppListViewTestAura : public views::ViewsTestBase, |
| - public ::testing::WithParamInterface<bool> { |
| + public ::testing::WithParamInterface<int> { |
| public: |
| AppListViewTestAura() {} |
| virtual ~AppListViewTestAura() {} |
| @@ -241,7 +291,7 @@ class AppListViewTestAura : public views::ViewsTestBase, |
| }; |
| class AppListViewTestDesktop : public views::ViewsTestBase, |
| - public ::testing::WithParamInterface<bool> { |
| + public ::testing::WithParamInterface<int> { |
| public: |
| AppListViewTestDesktop() {} |
| virtual ~AppListViewTestDesktop() {} |
| @@ -322,11 +372,11 @@ TEST_P(AppListViewTestDesktop, ReshowWithOpenFolder) { |
| INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| AppListViewTestAura, |
| - ::testing::Bool()); |
| + ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| AppListViewTestDesktop, |
| - ::testing::Bool()); |
| + ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| } // namespace test |
| } // namespace app_list |