| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 view->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, | 65 view->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, |
| 66 center, | 66 center, |
| 67 center, | 67 center, |
| 68 ui::EF_LEFT_MOUSE_BUTTON, | 68 ui::EF_LEFT_MOUSE_BUTTON, |
| 69 ui::EF_LEFT_MOUSE_BUTTON)); | 69 ui::EF_LEFT_MOUSE_BUTTON)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Choose a set that is 3 regular app list pages and 2 landscape app list pages. | 72 // Choose a set that is 3 regular app list pages and 2 landscape app list pages. |
| 73 const int kInitialItems = 34; | 73 const int kInitialItems = 34; |
| 74 | 74 |
| 75 class TestTileSearchResult : public TestSearchResult { | 75 class TestStartPageSearchResult : public TestSearchResult { |
| 76 public: | 76 public: |
| 77 TestTileSearchResult() { set_display_type(DISPLAY_TILE); } | 77 TestStartPageSearchResult() { set_display_type(DISPLAY_RECOMMENDATION); } |
| 78 ~TestTileSearchResult() override {} | 78 ~TestStartPageSearchResult() override {} |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 DISALLOW_COPY_AND_ASSIGN(TestTileSearchResult); | 81 DISALLOW_COPY_AND_ASSIGN(TestStartPageSearchResult); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 // Allows the same tests to run with different contexts: either an Ash-style | 84 // Allows the same tests to run with different contexts: either an Ash-style |
| 85 // root window or a desktop window tree host. | 85 // root window or a desktop window tree host. |
| 86 class AppListViewTestContext { | 86 class AppListViewTestContext { |
| 87 public: | 87 public: |
| 88 AppListViewTestContext(int test_type, gfx::NativeView parent); | 88 AppListViewTestContext(int test_type, gfx::NativeView parent); |
| 89 ~AppListViewTestContext(); | 89 ~AppListViewTestContext(); |
| 90 | 90 |
| 91 // Test displaying the app list and performs a standard set of checks on its | 91 // Test displaying the app list and performs a standard set of checks on its |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 EXPECT_TRUE(start_page_view->all_apps_button()->visible()); | 456 EXPECT_TRUE(start_page_view->all_apps_button()->visible()); |
| 457 SimulateClick(start_page_view->all_apps_button()); | 457 SimulateClick(start_page_view->all_apps_button()); |
| 458 main_view->contents_view()->Layout(); | 458 main_view->contents_view()->Layout(); |
| 459 EXPECT_TRUE(IsStateShown(AppListModel::STATE_APPS)); | 459 EXPECT_TRUE(IsStateShown(AppListModel::STATE_APPS)); |
| 460 | 460 |
| 461 // Hiding and showing the search box should not affect the app list's | 461 // Hiding and showing the search box should not affect the app list's |
| 462 // preferred size. This is a regression test for http://crbug.com/386912. | 462 // preferred size. This is a regression test for http://crbug.com/386912. |
| 463 EXPECT_EQ(view_size.ToString(), view_->GetPreferredSize().ToString()); | 463 EXPECT_EQ(view_size.ToString(), view_->GetPreferredSize().ToString()); |
| 464 | 464 |
| 465 // Check tiles hide and show on deletion and addition. | 465 // Check tiles hide and show on deletion and addition. |
| 466 model->results()->Add(new TestTileSearchResult()); | 466 model->results()->Add(new TestStartPageSearchResult()); |
| 467 start_page_view->UpdateForTesting(); | 467 start_page_view->UpdateForTesting(); |
| 468 EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views())); | 468 EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views())); |
| 469 model->results()->DeleteAll(); | 469 model->results()->DeleteAll(); |
| 470 start_page_view->UpdateForTesting(); | 470 start_page_view->UpdateForTesting(); |
| 471 EXPECT_EQ(0u, GetVisibleViews(start_page_view->tile_views())); | 471 EXPECT_EQ(0u, GetVisibleViews(start_page_view->tile_views())); |
| 472 } else { | 472 } else { |
| 473 EXPECT_EQ(NULL, start_page_view); | 473 EXPECT_EQ(NULL, start_page_view); |
| 474 } | 474 } |
| 475 | 475 |
| 476 Close(); | 476 Close(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 EXPECT_EQ(1, GetPaginationModel()->total_pages()); | 545 EXPECT_EQ(1, GetPaginationModel()->total_pages()); |
| 546 | 546 |
| 547 StartPageView* start_page_view = | 547 StartPageView* start_page_view = |
| 548 view_->app_list_main_view()->contents_view()->start_page_view(); | 548 view_->app_list_main_view()->contents_view()->start_page_view(); |
| 549 if (test_type_ == EXPERIMENTAL) | 549 if (test_type_ == EXPERIMENTAL) |
| 550 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); | 550 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); |
| 551 else | 551 else |
| 552 EXPECT_EQ(NULL, start_page_view); | 552 EXPECT_EQ(NULL, start_page_view); |
| 553 | 553 |
| 554 // New model updates should be processed by the start page view. | 554 // New model updates should be processed by the start page view. |
| 555 delegate_->GetTestModel()->results()->Add(new TestTileSearchResult()); | 555 delegate_->GetTestModel()->results()->Add(new TestStartPageSearchResult()); |
| 556 if (test_type_ == EXPERIMENTAL) { | 556 if (test_type_ == EXPERIMENTAL) { |
| 557 start_page_view->UpdateForTesting(); | 557 start_page_view->UpdateForTesting(); |
| 558 EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views())); | 558 EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views())); |
| 559 } | 559 } |
| 560 | 560 |
| 561 // Old model updates should be ignored. | 561 // Old model updates should be ignored. |
| 562 original_test_model->results()->Add(new TestTileSearchResult()); | 562 original_test_model->results()->Add(new TestStartPageSearchResult()); |
| 563 original_test_model->results()->Add(new TestTileSearchResult()); | 563 original_test_model->results()->Add(new TestStartPageSearchResult()); |
| 564 if (test_type_ == EXPERIMENTAL) { | 564 if (test_type_ == EXPERIMENTAL) { |
| 565 start_page_view->UpdateForTesting(); | 565 start_page_view->UpdateForTesting(); |
| 566 EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views())); | 566 EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views())); |
| 567 } | 567 } |
| 568 | 568 |
| 569 Close(); | 569 Close(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 void AppListViewTestContext::RunSearchResultsTest() { | 572 void AppListViewTestContext::RunSearchResultsTest() { |
| 573 EXPECT_FALSE(view_->GetWidget()->IsVisible()); | 573 EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 816 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| 817 AppListViewTestAura, | 817 AppListViewTestAura, |
| 818 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 818 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 819 | 819 |
| 820 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 820 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 821 AppListViewTestDesktop, | 821 AppListViewTestDesktop, |
| 822 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 822 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 823 | 823 |
| 824 } // namespace test | 824 } // namespace test |
| 825 } // namespace app_list | 825 } // namespace app_list |
| OLD | NEW |