Chromium Code Reviews| 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 "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/app_list/app_list_switches.h" | 11 #include "ui/app_list/app_list_switches.h" |
| 12 #include "ui/app_list/pagination_model.h" | 12 #include "ui/app_list/pagination_model.h" |
| 13 #include "ui/app_list/test/app_list_test_model.h" | 13 #include "ui/app_list/test/app_list_test_model.h" |
| 14 #include "ui/app_list/test/app_list_test_view_delegate.h" | 14 #include "ui/app_list/test/app_list_test_view_delegate.h" |
| 15 #include "ui/app_list/views/app_list_folder_view.h" | 15 #include "ui/app_list/views/app_list_folder_view.h" |
| 16 #include "ui/app_list/views/app_list_main_view.h" | 16 #include "ui/app_list/views/app_list_main_view.h" |
| 17 #include "ui/app_list/views/apps_container_view.h" | 17 #include "ui/app_list/views/apps_container_view.h" |
| 18 #include "ui/app_list/views/apps_grid_view.h" | 18 #include "ui/app_list/views/apps_grid_view.h" |
| 19 #include "ui/app_list/views/contents_view.h" | 19 #include "ui/app_list/views/contents_view.h" |
| 20 #include "ui/app_list/views/search_box_view.h" | 20 #include "ui/app_list/views/search_box_view.h" |
| 21 #include "ui/app_list/views/search_result_list_view.h" | |
| 21 #include "ui/app_list/views/start_page_view.h" | 22 #include "ui/app_list/views/start_page_view.h" |
| 22 #include "ui/app_list/views/test/apps_grid_view_test_api.h" | 23 #include "ui/app_list/views/test/apps_grid_view_test_api.h" |
| 23 #include "ui/app_list/views/tile_item_view.h" | 24 #include "ui/app_list/views/tile_item_view.h" |
| 24 #include "ui/aura/test/aura_test_base.h" | 25 #include "ui/aura/test/aura_test_base.h" |
| 25 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 26 #include "ui/views/test/views_test_base.h" | 27 #include "ui/views/test/views_test_base.h" |
| 27 #include "ui/views/views_delegate.h" | 28 #include "ui/views/views_delegate.h" |
| 28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 29 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 29 | 30 |
| 30 namespace app_list { | 31 namespace app_list { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 // top level views. Then closes the window. | 70 // top level views. Then closes the window. |
| 70 void RunDisplayTest(); | 71 void RunDisplayTest(); |
| 71 | 72 |
| 72 // Hides and reshows the app list with a folder open, expecting the main grid | 73 // Hides and reshows the app list with a folder open, expecting the main grid |
| 73 // view to be shown. | 74 // view to be shown. |
| 74 void RunReshowWithOpenFolderTest(); | 75 void RunReshowWithOpenFolderTest(); |
| 75 | 76 |
| 76 // Tests displaying of the experimental app list and shows the start page. | 77 // Tests displaying of the experimental app list and shows the start page. |
| 77 void RunStartPageTest(); | 78 void RunStartPageTest(); |
| 78 | 79 |
| 79 // Tests that changing the App List profile. | 80 // Tests changing the App List profile. |
| 80 void RunProfileChangeTest(); | 81 void RunProfileChangeTest(); |
| 81 | 82 |
| 83 // Tests displaying of the search results. | |
| 84 void RunSearchResultsTest(); | |
| 85 | |
| 82 // A standard set of checks on a view, e.g., ensuring it is drawn and visible. | 86 // A standard set of checks on a view, e.g., ensuring it is drawn and visible. |
| 83 static void CheckView(views::View* subview); | 87 static void CheckView(views::View* subview); |
| 84 | 88 |
| 85 // Invoked when the Widget is closing, and the view it contains is about to | 89 // Invoked when the Widget is closing, and the view it contains is about to |
| 86 // be torn down. This only occurs in a run loop and will be used as a signal | 90 // be torn down. This only occurs in a run loop and will be used as a signal |
| 87 // to quit. | 91 // to quit. |
| 88 void NativeWidgetClosing() { | 92 void NativeWidgetClosing() { |
| 89 view_ = NULL; | 93 view_ = NULL; |
| 90 run_loop_->Quit(); | 94 run_loop_->Quit(); |
| 91 } | 95 } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views())); | 352 EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| 349 | 353 |
| 350 // Old model updates should be ignored. | 354 // Old model updates should be ignored. |
| 351 original_test_model->CreateAndAddItem("Test App 2"); | 355 original_test_model->CreateAndAddItem("Test App 2"); |
| 352 if (test_type_ == EXPERIMENTAL) | 356 if (test_type_ == EXPERIMENTAL) |
| 353 EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views())); | 357 EXPECT_EQ(2u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| 354 | 358 |
| 355 Close(); | 359 Close(); |
| 356 } | 360 } |
| 357 | 361 |
| 362 void AppListViewTestContext::RunSearchResultsTest() { | |
| 363 EXPECT_FALSE(view_->GetWidget()->IsVisible()); | |
| 364 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); | |
| 365 AppListTestModel* model = delegate_->GetTestModel(); | |
| 366 model->PopulateApps(3); | |
| 367 | |
| 368 Show(); | |
| 369 | |
| 370 AppListMainView* main_view = view_->app_list_main_view(); | |
| 371 ContentsView* contents_view = main_view->contents_view(); | |
| 372 contents_view->SetActivePage( | |
| 373 contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS)); | |
| 374 EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view())); | |
| 375 | |
| 376 // Show the search results. | |
| 377 contents_view->ShowSearchResults(true); | |
|
tapted
2014/06/12 05:43:28
perhaps before this, something like
if (test_type
calamity
2014/06/12 07:09:37
I set the page to the apps page to have a consiste
| |
| 378 contents_view->Layout(); | |
| 379 EXPECT_TRUE(contents_view->IsShowingSearchResults()); | |
| 380 EXPECT_TRUE(main_view->search_box_view()->visible()); | |
| 381 | |
| 382 if (test_type_ == EXPERIMENTAL) { | |
| 383 EXPECT_TRUE( | |
| 384 contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_START)); | |
| 385 EXPECT_TRUE(IsViewAtOrigin(contents_view->start_page_view())); | |
| 386 } else { | |
| 387 EXPECT_TRUE(contents_view->IsNamedPageActive( | |
| 388 ContentsView::NAMED_PAGE_SEARCH_RESULTS)); | |
| 389 EXPECT_TRUE(IsViewAtOrigin(contents_view->search_results_view())); | |
| 390 } | |
| 391 | |
| 392 // Hide the search results. | |
| 393 contents_view->ShowSearchResults(false); | |
| 394 contents_view->Layout(); | |
| 395 EXPECT_FALSE(contents_view->IsShowingSearchResults()); | |
| 396 if (test_type_ == EXPERIMENTAL) { | |
| 397 EXPECT_TRUE( | |
| 398 contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_START)); | |
| 399 EXPECT_TRUE(IsViewAtOrigin(contents_view->start_page_view())); | |
| 400 EXPECT_FALSE(main_view->search_box_view()->visible()); | |
| 401 } else { | |
| 402 EXPECT_TRUE( | |
| 403 contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_APPS)); | |
| 404 EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view())); | |
| 405 } | |
|
tapted
2014/06/12 05:43:28
EXPECT_TRUE(main_view->search_box_view()->visible(
calamity
2014/06/12 07:09:37
Done.
| |
| 406 | |
| 407 Close(); | |
| 408 } | |
| 409 | |
| 358 class AppListViewTestAura : public views::ViewsTestBase, | 410 class AppListViewTestAura : public views::ViewsTestBase, |
| 359 public ::testing::WithParamInterface<int> { | 411 public ::testing::WithParamInterface<int> { |
| 360 public: | 412 public: |
| 361 AppListViewTestAura() {} | 413 AppListViewTestAura() {} |
| 362 virtual ~AppListViewTestAura() {} | 414 virtual ~AppListViewTestAura() {} |
| 363 | 415 |
| 364 // testing::Test overrides: | 416 // testing::Test overrides: |
| 365 virtual void SetUp() OVERRIDE { | 417 virtual void SetUp() OVERRIDE { |
| 366 views::ViewsTestBase::SetUp(); | 418 views::ViewsTestBase::SetUp(); |
| 367 test_context_.reset(new AppListViewTestContext(GetParam(), GetContext())); | 419 test_context_.reset(new AppListViewTestContext(GetParam(), GetContext())); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 | 522 |
| 471 // Tests that the profile changes operate correctly. | 523 // Tests that the profile changes operate correctly. |
| 472 TEST_P(AppListViewTestAura, ProfileChangeTest) { | 524 TEST_P(AppListViewTestAura, ProfileChangeTest) { |
| 473 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); | 525 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); |
| 474 } | 526 } |
| 475 | 527 |
| 476 TEST_P(AppListViewTestDesktop, ProfileChangeTest) { | 528 TEST_P(AppListViewTestDesktop, ProfileChangeTest) { |
| 477 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); | 529 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); |
| 478 } | 530 } |
| 479 | 531 |
| 532 // Tests that the correct views are displayed for showing search results. | |
| 533 TEST_P(AppListViewTestAura, SearchResultsTest) { | |
| 534 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest()); | |
| 535 } | |
| 536 | |
| 537 TEST_P(AppListViewTestDesktop, SearchResultsTest) { | |
| 538 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest()); | |
| 539 } | |
| 540 | |
| 480 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 541 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| 481 AppListViewTestAura, | 542 AppListViewTestAura, |
| 482 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 543 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 483 | 544 |
| 484 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 545 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 485 AppListViewTestDesktop, | 546 AppListViewTestDesktop, |
| 486 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 547 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 487 | 548 |
| 488 } // namespace test | 549 } // namespace test |
| 489 } // namespace app_list | 550 } // namespace app_list |
| OLD | NEW |