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" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/app_list/app_list_switches.h" | 12 #include "ui/app_list/app_list_switches.h" |
13 #include "ui/app_list/pagination_model.h" | 13 #include "ui/app_list/pagination_model.h" |
14 #include "ui/app_list/search_box_model.h" | 14 #include "ui/app_list/search_box_model.h" |
15 #include "ui/app_list/test/app_list_test_model.h" | 15 #include "ui/app_list/test/app_list_test_model.h" |
16 #include "ui/app_list/test/app_list_test_view_delegate.h" | 16 #include "ui/app_list/test/app_list_test_view_delegate.h" |
17 #include "ui/app_list/views/app_list_folder_view.h" | 17 #include "ui/app_list/views/app_list_folder_view.h" |
18 #include "ui/app_list/views/app_list_main_view.h" | 18 #include "ui/app_list/views/app_list_main_view.h" |
19 #include "ui/app_list/views/apps_container_view.h" | 19 #include "ui/app_list/views/apps_container_view.h" |
20 #include "ui/app_list/views/apps_grid_view.h" | 20 #include "ui/app_list/views/apps_grid_view.h" |
21 #include "ui/app_list/views/contents_switcher_view.h" | 21 #include "ui/app_list/views/contents_switcher_view.h" |
22 #include "ui/app_list/views/contents_view.h" | 22 #include "ui/app_list/views/contents_view.h" |
23 #include "ui/app_list/views/search_box_view.h" | 23 #include "ui/app_list/views/search_box_view.h" |
24 #include "ui/app_list/views/search_result_list_view.h" | 24 #include "ui/app_list/views/search_result_list_view.h" |
25 #include "ui/app_list/views/start_page_view.h" | 25 #include "ui/app_list/views/start_page_view.h" |
26 #include "ui/app_list/views/test/apps_grid_view_test_api.h" | 26 #include "ui/app_list/views/test/apps_grid_view_test_api.h" |
27 #include "ui/app_list/views/tile_item_view.h" | 27 #include "ui/app_list/views/tile_item_view.h" |
28 #include "ui/aura/test/aura_test_base.h" | |
29 #include "ui/aura/window.h" | |
30 #include "ui/views/controls/textfield/textfield.h" | 28 #include "ui/views/controls/textfield/textfield.h" |
31 #include "ui/views/test/views_test_base.h" | 29 #include "ui/views/test/views_test_base.h" |
32 #include "ui/views/views_delegate.h" | 30 #include "ui/views/views_delegate.h" |
33 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 31 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
34 | 32 |
35 namespace app_list { | 33 namespace app_list { |
36 namespace test { | 34 namespace test { |
37 | 35 |
38 namespace { | 36 namespace { |
39 | 37 |
(...skipping 20 matching lines...) Expand all Loading... |
60 return count; | 58 return count; |
61 } | 59 } |
62 | 60 |
63 // 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. |
64 const int kInitialItems = 34; | 62 const int kInitialItems = 34; |
65 | 63 |
66 // Allows the same tests to run with different contexts: either an Ash-style | 64 // Allows the same tests to run with different contexts: either an Ash-style |
67 // root window or a desktop window tree host. | 65 // root window or a desktop window tree host. |
68 class AppListViewTestContext { | 66 class AppListViewTestContext { |
69 public: | 67 public: |
70 AppListViewTestContext(int test_type, aura::Window* parent); | 68 AppListViewTestContext(int test_type, gfx::NativeView parent); |
71 ~AppListViewTestContext(); | 69 ~AppListViewTestContext(); |
72 | 70 |
73 // Test displaying the app list and performs a standard set of checks on its | 71 // Test displaying the app list and performs a standard set of checks on its |
74 // top level views. Then closes the window. | 72 // top level views. Then closes the window. |
75 void RunDisplayTest(); | 73 void RunDisplayTest(); |
76 | 74 |
77 // Hides and reshows the app list with a folder open, expecting the main grid | 75 // Hides and reshows the app list with a folder open, expecting the main grid |
78 // view to be shown. | 76 // view to be shown. |
79 void RunReshowWithOpenFolderTest(); | 77 void RunReshowWithOpenFolderTest(); |
80 | 78 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Overridden from app_list::test::AppListTestViewDelegate: | 141 // Overridden from app_list::test::AppListTestViewDelegate: |
144 virtual void ViewClosing() OVERRIDE { parent_->NativeWidgetClosing(); } | 142 virtual void ViewClosing() OVERRIDE { parent_->NativeWidgetClosing(); } |
145 | 143 |
146 private: | 144 private: |
147 AppListViewTestContext* parent_; | 145 AppListViewTestContext* parent_; |
148 | 146 |
149 DISALLOW_COPY_AND_ASSIGN(UnitTestViewDelegate); | 147 DISALLOW_COPY_AND_ASSIGN(UnitTestViewDelegate); |
150 }; | 148 }; |
151 | 149 |
152 AppListViewTestContext::AppListViewTestContext(int test_type, | 150 AppListViewTestContext::AppListViewTestContext(int test_type, |
153 aura::Window* parent) | 151 gfx::NativeView parent) |
154 : test_type_(static_cast<TestType>(test_type)) { | 152 : test_type_(static_cast<TestType>(test_type)) { |
155 switch (test_type_) { | 153 switch (test_type_) { |
156 case NORMAL: | 154 case NORMAL: |
157 break; | 155 break; |
158 case LANDSCAPE: | 156 case LANDSCAPE: |
159 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 157 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
160 switches::kEnableCenteredAppList); | 158 switches::kEnableCenteredAppList); |
161 break; | 159 break; |
162 case EXPERIMENTAL: | 160 case EXPERIMENTAL: |
163 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 161 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 521 |
524 class AppListViewTestAura : public views::ViewsTestBase, | 522 class AppListViewTestAura : public views::ViewsTestBase, |
525 public ::testing::WithParamInterface<int> { | 523 public ::testing::WithParamInterface<int> { |
526 public: | 524 public: |
527 AppListViewTestAura() {} | 525 AppListViewTestAura() {} |
528 virtual ~AppListViewTestAura() {} | 526 virtual ~AppListViewTestAura() {} |
529 | 527 |
530 // testing::Test overrides: | 528 // testing::Test overrides: |
531 virtual void SetUp() OVERRIDE { | 529 virtual void SetUp() OVERRIDE { |
532 views::ViewsTestBase::SetUp(); | 530 views::ViewsTestBase::SetUp(); |
533 test_context_.reset(new AppListViewTestContext(GetParam(), GetContext())); | 531 |
| 532 // On Ash (only) the app list is placed into an aura::Window "container", |
| 533 // which is also used to determine the context. In tests, use the ash root |
| 534 // window as the parent. This only works on aura where the root window is a |
| 535 // NativeView as well as a NativeWindow. |
| 536 gfx::NativeView container = NULL; |
| 537 #if defined(USE_AURA) |
| 538 container = GetContext(); |
| 539 #endif |
| 540 |
| 541 test_context_.reset(new AppListViewTestContext(GetParam(), container)); |
534 } | 542 } |
535 | 543 |
536 virtual void TearDown() OVERRIDE { | 544 virtual void TearDown() OVERRIDE { |
537 test_context_.reset(); | 545 test_context_.reset(); |
538 views::ViewsTestBase::TearDown(); | 546 views::ViewsTestBase::TearDown(); |
539 } | 547 } |
540 | 548 |
541 protected: | 549 protected: |
542 scoped_ptr<AppListViewTestContext> test_context_; | 550 scoped_ptr<AppListViewTestContext> test_context_; |
543 | 551 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 672 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
665 AppListViewTestAura, | 673 AppListViewTestAura, |
666 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 674 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
667 | 675 |
668 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 676 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
669 AppListViewTestDesktop, | 677 AppListViewTestDesktop, |
670 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 678 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
671 | 679 |
672 } // namespace test | 680 } // namespace test |
673 } // namespace app_list | 681 } // namespace app_list |
OLD | NEW |