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

Unified Diff: ui/app_list/views/app_list_view_unittest.cc

Issue 305123002: Fix crash in the experimental app list StartPageView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add profile change tests Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/test/app_list_test_view_delegate.cc ('k') | ui/app_list/views/start_page_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « ui/app_list/test/app_list_test_view_delegate.cc ('k') | ui/app_list/views/start_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698