| 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 "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 "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ++it) { | 54 ++it) { |
| 55 if ((*it)->visible()) | 55 if ((*it)->visible()) |
| 56 count++; | 56 count++; |
| 57 } | 57 } |
| 58 return count; | 58 return count; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Choose a set that is 3 regular app list pages and 2 landscape app list pages. | 61 // Choose a set that is 3 regular app list pages and 2 landscape app list pages. |
| 62 const int kInitialItems = 34; | 62 const int kInitialItems = 34; |
| 63 | 63 |
| 64 class TestTileSearchResult : public SearchResult { |
| 65 public: |
| 66 TestTileSearchResult() { set_display_type(DISPLAY_TILE); } |
| 67 virtual ~TestTileSearchResult() {} |
| 68 |
| 69 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(TestTileSearchResult); |
| 71 }; |
| 72 |
| 64 // Allows the same tests to run with different contexts: either an Ash-style | 73 // Allows the same tests to run with different contexts: either an Ash-style |
| 65 // root window or a desktop window tree host. | 74 // root window or a desktop window tree host. |
| 66 class AppListViewTestContext { | 75 class AppListViewTestContext { |
| 67 public: | 76 public: |
| 68 AppListViewTestContext(int test_type, gfx::NativeView parent); | 77 AppListViewTestContext(int test_type, gfx::NativeView parent); |
| 69 ~AppListViewTestContext(); | 78 ~AppListViewTestContext(); |
| 70 | 79 |
| 71 // Test displaying the app list and performs a standard set of checks on its | 80 // Test displaying the app list and performs a standard set of checks on its |
| 72 // top level views. Then closes the window. | 81 // top level views. Then closes the window. |
| 73 void RunDisplayTest(); | 82 void RunDisplayTest(); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); | 315 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
| 307 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); | 316 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); |
| 308 if (test_type_ == EXPERIMENTAL) { | 317 if (test_type_ == EXPERIMENTAL) { |
| 309 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); | 318 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); |
| 310 | 319 |
| 311 // Show the start page view. | 320 // Show the start page view. |
| 312 ContentsView* contents_view = main_view->contents_view(); | 321 ContentsView* contents_view = main_view->contents_view(); |
| 313 ShowContentsViewPageAndVerify(contents_view->GetPageIndexForNamedPage( | 322 ShowContentsViewPageAndVerify(contents_view->GetPageIndexForNamedPage( |
| 314 ContentsView::NAMED_PAGE_START)); | 323 ContentsView::NAMED_PAGE_START)); |
| 315 EXPECT_FALSE(main_view->search_box_view()->visible()); | 324 EXPECT_FALSE(main_view->search_box_view()->visible()); |
| 316 EXPECT_EQ(3u, GetVisibleTileItemViews(start_page_view->tile_views())); | |
| 317 | 325 |
| 318 gfx::Size view_size(view_->GetPreferredSize()); | 326 gfx::Size view_size(view_->GetPreferredSize()); |
| 319 ShowContentsViewPageAndVerify( | 327 ShowContentsViewPageAndVerify( |
| 320 contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS)); | 328 contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS)); |
| 321 EXPECT_TRUE(main_view->search_box_view()->visible()); | 329 EXPECT_TRUE(main_view->search_box_view()->visible()); |
| 322 | 330 |
| 323 // Hiding and showing the search box should not affect the app list's | 331 // Hiding and showing the search box should not affect the app list's |
| 324 // preferred size. This is a regression test for http://crbug.com/386912. | 332 // preferred size. This is a regression test for http://crbug.com/386912. |
| 325 EXPECT_EQ(view_size.ToString(), view_->GetPreferredSize().ToString()); | 333 EXPECT_EQ(view_size.ToString(), view_->GetPreferredSize().ToString()); |
| 326 | 334 |
| 327 // Check tiles hide and show on deletion and addition. | 335 // Check tiles hide and show on deletion and addition. |
| 328 model->CreateAndAddItem("Test app"); | 336 model->results()->Add(new TestTileSearchResult()); |
| 329 EXPECT_EQ(4u, GetVisibleTileItemViews(start_page_view->tile_views())); | 337 start_page_view->UpdateForTesting(); |
| 330 model->DeleteItem(model->GetItemName(0)); | 338 EXPECT_EQ(1u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| 331 EXPECT_EQ(3u, GetVisibleTileItemViews(start_page_view->tile_views())); | 339 model->results()->RemoveAll(); |
| 340 start_page_view->UpdateForTesting(); |
| 341 EXPECT_EQ(0u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| 332 } else { | 342 } else { |
| 333 EXPECT_EQ(NULL, start_page_view); | 343 EXPECT_EQ(NULL, start_page_view); |
| 334 } | 344 } |
| 335 | 345 |
| 336 Close(); | 346 Close(); |
| 337 } | 347 } |
| 338 | 348 |
| 339 void AppListViewTestContext::RunPageSwitchingAnimationTest() { | 349 void AppListViewTestContext::RunPageSwitchingAnimationTest() { |
| 340 if (test_type_ == EXPERIMENTAL) { | 350 if (test_type_ == EXPERIMENTAL) { |
| 341 Show(); | 351 Show(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 413 |
| 404 StartPageView* start_page_view = | 414 StartPageView* start_page_view = |
| 405 view_->app_list_main_view()->contents_view()->start_page_view(); | 415 view_->app_list_main_view()->contents_view()->start_page_view(); |
| 406 ContentsSwitcherView* contents_switcher_view = | 416 ContentsSwitcherView* contents_switcher_view = |
| 407 view_->app_list_main_view()->contents_switcher_view(); | 417 view_->app_list_main_view()->contents_switcher_view(); |
| 408 if (test_type_ == EXPERIMENTAL) { | 418 if (test_type_ == EXPERIMENTAL) { |
| 409 EXPECT_NO_FATAL_FAILURE(CheckView(contents_switcher_view)); | 419 EXPECT_NO_FATAL_FAILURE(CheckView(contents_switcher_view)); |
| 410 EXPECT_EQ(view_->app_list_main_view()->contents_view(), | 420 EXPECT_EQ(view_->app_list_main_view()->contents_view(), |
| 411 contents_switcher_view->contents_view()); | 421 contents_switcher_view->contents_view()); |
| 412 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); | 422 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); |
| 413 EXPECT_EQ(1u, GetVisibleTileItemViews(start_page_view->tile_views())); | |
| 414 } else { | 423 } else { |
| 415 EXPECT_EQ(NULL, contents_switcher_view); | 424 EXPECT_EQ(NULL, contents_switcher_view); |
| 416 EXPECT_EQ(NULL, start_page_view); | 425 EXPECT_EQ(NULL, start_page_view); |
| 417 } | 426 } |
| 418 | 427 |
| 419 // New model updates should be processed by the start page view. | 428 // New model updates should be processed by the start page view. |
| 420 delegate_->GetTestModel()->CreateAndAddItem("Test App"); | 429 delegate_->GetTestModel()->results()->Add(new TestTileSearchResult()); |
| 421 if (test_type_ == EXPERIMENTAL) | 430 if (test_type_ == EXPERIMENTAL) { |
| 422 EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views())); | 431 start_page_view->UpdateForTesting(); |
| 432 EXPECT_EQ(1u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| 433 } |
| 423 | 434 |
| 424 // Old model updates should be ignored. | 435 // Old model updates should be ignored. |
| 425 original_test_model->CreateAndAddItem("Test App 2"); | 436 original_test_model->results()->Add(new TestTileSearchResult()); |
| 426 if (test_type_ == EXPERIMENTAL) | 437 original_test_model->results()->Add(new TestTileSearchResult()); |
| 427 EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views())); | 438 if (test_type_ == EXPERIMENTAL) { |
| 439 start_page_view->UpdateForTesting(); |
| 440 EXPECT_EQ(1u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| 441 } |
| 428 | 442 |
| 429 Close(); | 443 Close(); |
| 430 } | 444 } |
| 431 | 445 |
| 432 void AppListViewTestContext::RunSearchResultsTest() { | 446 void AppListViewTestContext::RunSearchResultsTest() { |
| 433 EXPECT_FALSE(view_->GetWidget()->IsVisible()); | 447 EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
| 434 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); | 448 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); |
| 435 AppListTestModel* model = delegate_->GetTestModel(); | 449 AppListTestModel* model = delegate_->GetTestModel(); |
| 436 model->PopulateApps(3); | 450 model->PopulateApps(3); |
| 437 | 451 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 686 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| 673 AppListViewTestAura, | 687 AppListViewTestAura, |
| 674 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 688 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 675 | 689 |
| 676 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 690 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 677 AppListViewTestDesktop, | 691 AppListViewTestDesktop, |
| 678 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 692 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 679 | 693 |
| 680 } // namespace test | 694 } // namespace test |
| 681 } // namespace app_list | 695 } // namespace app_list |
| OLD | NEW |