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

Side by Side 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, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // top level views. Then closes the window. 69 // top level views. Then closes the window.
70 void RunDisplayTest(); 70 void RunDisplayTest();
71 71
72 // Hides and reshows the app list with a folder open, expecting the main grid 72 // Hides and reshows the app list with a folder open, expecting the main grid
73 // view to be shown. 73 // view to be shown.
74 void RunReshowWithOpenFolderTest(); 74 void RunReshowWithOpenFolderTest();
75 75
76 // Tests displaying of the experimental app list and shows the start page. 76 // Tests displaying of the experimental app list and shows the start page.
77 void RunStartPageTest(); 77 void RunStartPageTest();
78 78
79 // Tests that changing the App List profile.
80 void RunProfileChangeTest();
81
79 // A standard set of checks on a view, e.g., ensuring it is drawn and visible. 82 // A standard set of checks on a view, e.g., ensuring it is drawn and visible.
80 static void CheckView(views::View* subview); 83 static void CheckView(views::View* subview);
81 84
82 // Invoked when the Widget is closing, and the view it contains is about to 85 // Invoked when the Widget is closing, and the view it contains is about to
83 // be torn down. This only occurs in a run loop and will be used as a signal 86 // be torn down. This only occurs in a run loop and will be used as a signal
84 // to quit. 87 // to quit.
85 void NativeWidgetClosing() { 88 void NativeWidgetClosing() {
86 view_ = NULL; 89 view_ = NULL;
87 run_loop_->Quit(); 90 run_loop_->Quit();
88 } 91 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 EXPECT_EQ(4u, GetVisibleTileItemViews(start_page_view->tile_views())); 297 EXPECT_EQ(4u, GetVisibleTileItemViews(start_page_view->tile_views()));
295 model->DeleteItem(model->GetItemName(0)); 298 model->DeleteItem(model->GetItemName(0));
296 EXPECT_EQ(3u, GetVisibleTileItemViews(start_page_view->tile_views())); 299 EXPECT_EQ(3u, GetVisibleTileItemViews(start_page_view->tile_views()));
297 } else { 300 } else {
298 EXPECT_EQ(NULL, start_page_view); 301 EXPECT_EQ(NULL, start_page_view);
299 } 302 }
300 303
301 Close(); 304 Close();
302 } 305 }
303 306
307 void AppListViewTestContext::RunProfileChangeTest() {
308 EXPECT_FALSE(view_->GetWidget()->IsVisible());
309 EXPECT_EQ(-1, pagination_model_.total_pages());
310 delegate_->GetTestModel()->PopulateApps(kInitialItems);
311
312 Show();
313
314 if (is_landscape())
315 EXPECT_EQ(2, pagination_model_.total_pages());
316 else
317 EXPECT_EQ(3, pagination_model_.total_pages());
318
319 AppListMainView* main_view = view_->app_list_main_view();
tapted 2014/05/30 09:01:39 nit: these 4 lines are probably redundant; being r
320 // Checks on the main view.
321 EXPECT_NO_FATAL_FAILURE(CheckView(main_view));
322 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view()));
323
324 // Change the profile. The original model needs to be kept alive for
325 // observers to unregister themselves.
326 scoped_ptr<AppListTestModel> original_test_model(
327 delegate_->ReleaseTestModel());
328 delegate_->set_next_profile_app_count(1);
329
330 // The original ContentsView is destroyed here.
331 view_->SetProfileByPath(base::FilePath());
332 EXPECT_EQ(1, pagination_model_.total_pages());
333
334 StartPageView* start_page_view =
335 main_view->contents_view()->start_page_view();
336 if (test_type_ == EXPERIMENTAL) {
337 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view));
338 EXPECT_EQ(1u, GetVisibleTileItemViews(start_page_view->tile_views()));
339 } else {
340 EXPECT_EQ(NULL, start_page_view);
341 }
342
343 // New model updates should be processed by the start page view.
344 delegate_->GetTestModel()->CreateAndAddItem("Test App");
345 if (test_type_ == EXPERIMENTAL)
346 EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views()));
347
348 // Old model updates should be ignored.
349 original_test_model->CreateAndAddItem("Test App 2");
350 if (test_type_ == EXPERIMENTAL)
351 EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views()));
352
353 Close();
354 }
355
304 class AppListViewTestAura : public views::ViewsTestBase, 356 class AppListViewTestAura : public views::ViewsTestBase,
305 public ::testing::WithParamInterface<int> { 357 public ::testing::WithParamInterface<int> {
306 public: 358 public:
307 AppListViewTestAura() {} 359 AppListViewTestAura() {}
308 virtual ~AppListViewTestAura() {} 360 virtual ~AppListViewTestAura() {}
309 361
310 // testing::Test overrides: 362 // testing::Test overrides:
311 virtual void SetUp() OVERRIDE { 363 virtual void SetUp() OVERRIDE {
312 views::ViewsTestBase::SetUp(); 364 views::ViewsTestBase::SetUp();
313 test_context_.reset(new AppListViewTestContext(GetParam(), GetContext())); 365 test_context_.reset(new AppListViewTestContext(GetParam(), GetContext()));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 459
408 // Tests that the start page view operates correctly. 460 // Tests that the start page view operates correctly.
409 TEST_P(AppListViewTestAura, StartPageTest) { 461 TEST_P(AppListViewTestAura, StartPageTest) {
410 EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest()); 462 EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest());
411 } 463 }
412 464
413 TEST_P(AppListViewTestDesktop, StartPageTest) { 465 TEST_P(AppListViewTestDesktop, StartPageTest) {
414 EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest()); 466 EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest());
415 } 467 }
416 468
469 // Tests that the profile changes operate correctly.
470 TEST_P(AppListViewTestAura, ProfileChangeTest) {
471 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest());
472 }
473
474 TEST_P(AppListViewTestDesktop, ProfileChangeTest) {
475 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest());
476 }
477
417 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, 478 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance,
418 AppListViewTestAura, 479 AppListViewTestAura,
419 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); 480 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END));
420 481
421 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, 482 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance,
422 AppListViewTestDesktop, 483 AppListViewTestDesktop,
423 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); 484 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END));
424 485
425 } // namespace test 486 } // namespace test
426 } // namespace app_list 487 } // namespace app_list
OLDNEW
« 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