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 5ead23f231f8331686d38a215181d2aff48411f2..e28e9c8959765dc7a2d4ca528c09ae22aa0b0083 100644 |
| --- a/ui/app_list/views/app_list_view_unittest.cc |
| +++ b/ui/app_list/views/app_list_view_unittest.cc |
| @@ -76,6 +76,9 @@ class AppListViewTestContext { |
| // Tests displaying of the experimental app list and shows the start page. |
| void RunStartPageTest(); |
| + // Tests that changing the App List profile. |
| + void RunProfileChangeTest(); |
| + |
| // A standard set of checks on a view, e.g., ensuring it is drawn and visible. |
| static void CheckView(views::View* subview); |
| @@ -301,6 +304,55 @@ void AppListViewTestContext::RunStartPageTest() { |
| Close(); |
| } |
| +void AppListViewTestContext::RunProfileChangeTest() { |
| + EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
| + EXPECT_EQ(-1, pagination_model_.total_pages()); |
| + delegate_->GetTestModel()->PopulateApps(kInitialItems); |
| + |
| + Show(); |
| + |
| + if (is_landscape()) |
| + EXPECT_EQ(2, pagination_model_.total_pages()); |
| + else |
| + EXPECT_EQ(3, pagination_model_.total_pages()); |
| + |
| + AppListMainView* main_view = view_->app_list_main_view(); |
|
tapted
2014/05/30 09:01:39
nit: these 4 lines are probably redundant; being r
|
| + // Checks on the main view. |
| + EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
| + EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); |
| + |
| + // Change the profile. The original model needs to be kept alive for |
| + // observers to unregister themselves. |
| + scoped_ptr<AppListTestModel> original_test_model( |
| + delegate_->ReleaseTestModel()); |
| + delegate_->set_next_profile_app_count(1); |
| + |
| + // The original ContentsView is destroyed here. |
| + view_->SetProfileByPath(base::FilePath()); |
| + EXPECT_EQ(1, pagination_model_.total_pages()); |
| + |
| + StartPageView* start_page_view = |
| + main_view->contents_view()->start_page_view(); |
| + if (test_type_ == EXPERIMENTAL) { |
| + EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); |
| + EXPECT_EQ(1u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| + } else { |
| + EXPECT_EQ(NULL, start_page_view); |
| + } |
| + |
| + // New model updates should be processed by the start page view. |
| + delegate_->GetTestModel()->CreateAndAddItem("Test App"); |
| + if (test_type_ == EXPERIMENTAL) |
| + EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| + |
| + // Old model updates should be ignored. |
| + original_test_model->CreateAndAddItem("Test App 2"); |
| + if (test_type_ == EXPERIMENTAL) |
| + EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| + |
| + Close(); |
| +} |
| + |
| class AppListViewTestAura : public views::ViewsTestBase, |
| public ::testing::WithParamInterface<int> { |
| public: |
| @@ -414,6 +466,15 @@ TEST_P(AppListViewTestDesktop, StartPageTest) { |
| EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest()); |
| } |
| +// Tests that the profile changes operate correctly. |
| +TEST_P(AppListViewTestAura, ProfileChangeTest) { |
| + EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); |
| +} |
| + |
| +TEST_P(AppListViewTestDesktop, ProfileChangeTest) { |
| + EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); |
| +} |
| + |
| INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| AppListViewTestAura, |
| ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |