| 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 } | 54 } |
| 55 return count; | 55 return count; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Choose a set that is 3 regular app list pages and 2 landscape app list pages. | 58 // Choose a set that is 3 regular app list pages and 2 landscape app list pages. |
| 59 const int kInitialItems = 34; | 59 const int kInitialItems = 34; |
| 60 | 60 |
| 61 class TestTileSearchResult : public TestSearchResult { | 61 class TestTileSearchResult : public TestSearchResult { |
| 62 public: | 62 public: |
| 63 TestTileSearchResult() { set_display_type(DISPLAY_TILE); } | 63 TestTileSearchResult() { set_display_type(DISPLAY_TILE); } |
| 64 virtual ~TestTileSearchResult() {} | 64 ~TestTileSearchResult() override {} |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(TestTileSearchResult); | 67 DISALLOW_COPY_AND_ASSIGN(TestTileSearchResult); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Allows the same tests to run with different contexts: either an Ash-style | 70 // Allows the same tests to run with different contexts: either an Ash-style |
| 71 // root window or a desktop window tree host. | 71 // root window or a desktop window tree host. |
| 72 class AppListViewTestContext { | 72 class AppListViewTestContext { |
| 73 public: | 73 public: |
| 74 AppListViewTestContext(int test_type, gfx::NativeView parent); | 74 AppListViewTestContext(int test_type, gfx::NativeView parent); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 // Extend the regular AppListTestViewDelegate to communicate back to the test | 135 // Extend the regular AppListTestViewDelegate to communicate back to the test |
| 136 // context. Note the test context doesn't simply inherit this, because the | 136 // context. Note the test context doesn't simply inherit this, because the |
| 137 // delegate is owned by the view. | 137 // delegate is owned by the view. |
| 138 class UnitTestViewDelegate : public app_list::test::AppListTestViewDelegate { | 138 class UnitTestViewDelegate : public app_list::test::AppListTestViewDelegate { |
| 139 public: | 139 public: |
| 140 UnitTestViewDelegate(AppListViewTestContext* parent) : parent_(parent) {} | 140 UnitTestViewDelegate(AppListViewTestContext* parent) : parent_(parent) {} |
| 141 | 141 |
| 142 // Overridden from app_list::AppListViewDelegate: | 142 // Overridden from app_list::AppListViewDelegate: |
| 143 virtual bool ShouldCenterWindow() const override { | 143 bool ShouldCenterWindow() const override { |
| 144 return app_list::switches::IsCenteredAppListEnabled(); | 144 return app_list::switches::IsCenteredAppListEnabled(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Overridden from app_list::test::AppListTestViewDelegate: | 147 // Overridden from app_list::test::AppListTestViewDelegate: |
| 148 virtual void ViewClosing() override { parent_->NativeWidgetClosing(); } | 148 void ViewClosing() override { parent_->NativeWidgetClosing(); } |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 AppListViewTestContext* parent_; | 151 AppListViewTestContext* parent_; |
| 152 | 152 |
| 153 DISALLOW_COPY_AND_ASSIGN(UnitTestViewDelegate); | 153 DISALLOW_COPY_AND_ASSIGN(UnitTestViewDelegate); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 AppListViewTestContext::AppListViewTestContext(int test_type, | 156 AppListViewTestContext::AppListViewTestContext(int test_type, |
| 157 gfx::NativeView parent) | 157 gfx::NativeView parent) |
| 158 : test_type_(static_cast<TestType>(test_type)) { | 158 : test_type_(static_cast<TestType>(test_type)) { |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 Close(); | 562 Close(); |
| 563 } | 563 } |
| 564 | 564 |
| 565 class AppListViewTestAura : public views::ViewsTestBase, | 565 class AppListViewTestAura : public views::ViewsTestBase, |
| 566 public ::testing::WithParamInterface<int> { | 566 public ::testing::WithParamInterface<int> { |
| 567 public: | 567 public: |
| 568 AppListViewTestAura() {} | 568 AppListViewTestAura() {} |
| 569 virtual ~AppListViewTestAura() {} | 569 virtual ~AppListViewTestAura() {} |
| 570 | 570 |
| 571 // testing::Test overrides: | 571 // testing::Test overrides: |
| 572 virtual void SetUp() override { | 572 void SetUp() override { |
| 573 views::ViewsTestBase::SetUp(); | 573 views::ViewsTestBase::SetUp(); |
| 574 | 574 |
| 575 // On Ash (only) the app list is placed into an aura::Window "container", | 575 // On Ash (only) the app list is placed into an aura::Window "container", |
| 576 // which is also used to determine the context. In tests, use the ash root | 576 // which is also used to determine the context. In tests, use the ash root |
| 577 // window as the parent. This only works on aura where the root window is a | 577 // window as the parent. This only works on aura where the root window is a |
| 578 // NativeView as well as a NativeWindow. | 578 // NativeView as well as a NativeWindow. |
| 579 gfx::NativeView container = NULL; | 579 gfx::NativeView container = NULL; |
| 580 #if defined(USE_AURA) | 580 #if defined(USE_AURA) |
| 581 container = GetContext(); | 581 container = GetContext(); |
| 582 #endif | 582 #endif |
| 583 | 583 |
| 584 test_context_.reset(new AppListViewTestContext(GetParam(), container)); | 584 test_context_.reset(new AppListViewTestContext(GetParam(), container)); |
| 585 } | 585 } |
| 586 | 586 |
| 587 virtual void TearDown() override { | 587 void TearDown() override { |
| 588 test_context_.reset(); | 588 test_context_.reset(); |
| 589 views::ViewsTestBase::TearDown(); | 589 views::ViewsTestBase::TearDown(); |
| 590 } | 590 } |
| 591 | 591 |
| 592 protected: | 592 protected: |
| 593 scoped_ptr<AppListViewTestContext> test_context_; | 593 scoped_ptr<AppListViewTestContext> test_context_; |
| 594 | 594 |
| 595 private: | 595 private: |
| 596 DISALLOW_COPY_AND_ASSIGN(AppListViewTestAura); | 596 DISALLOW_COPY_AND_ASSIGN(AppListViewTestAura); |
| 597 }; | 597 }; |
| 598 | 598 |
| 599 class AppListViewTestDesktop : public views::ViewsTestBase, | 599 class AppListViewTestDesktop : public views::ViewsTestBase, |
| 600 public ::testing::WithParamInterface<int> { | 600 public ::testing::WithParamInterface<int> { |
| 601 public: | 601 public: |
| 602 AppListViewTestDesktop() {} | 602 AppListViewTestDesktop() {} |
| 603 virtual ~AppListViewTestDesktop() {} | 603 virtual ~AppListViewTestDesktop() {} |
| 604 | 604 |
| 605 // testing::Test overrides: | 605 // testing::Test overrides: |
| 606 virtual void SetUp() override { | 606 void SetUp() override { |
| 607 set_views_delegate(new AppListViewTestViewsDelegate(this)); | 607 set_views_delegate(new AppListViewTestViewsDelegate(this)); |
| 608 views::ViewsTestBase::SetUp(); | 608 views::ViewsTestBase::SetUp(); |
| 609 test_context_.reset(new AppListViewTestContext(GetParam(), NULL)); | 609 test_context_.reset(new AppListViewTestContext(GetParam(), NULL)); |
| 610 } | 610 } |
| 611 | 611 |
| 612 virtual void TearDown() override { | 612 void TearDown() override { |
| 613 test_context_.reset(); | 613 test_context_.reset(); |
| 614 views::ViewsTestBase::TearDown(); | 614 views::ViewsTestBase::TearDown(); |
| 615 } | 615 } |
| 616 | 616 |
| 617 protected: | 617 protected: |
| 618 scoped_ptr<AppListViewTestContext> test_context_; | 618 scoped_ptr<AppListViewTestContext> test_context_; |
| 619 | 619 |
| 620 private: | 620 private: |
| 621 class AppListViewTestViewsDelegate : public views::TestViewsDelegate { | 621 class AppListViewTestViewsDelegate : public views::TestViewsDelegate { |
| 622 public: | 622 public: |
| 623 AppListViewTestViewsDelegate(AppListViewTestDesktop* parent) | 623 AppListViewTestViewsDelegate(AppListViewTestDesktop* parent) |
| 624 : parent_(parent) {} | 624 : parent_(parent) {} |
| 625 | 625 |
| 626 // Overridden from views::ViewsDelegate: | 626 // Overridden from views::ViewsDelegate: |
| 627 virtual void OnBeforeWidgetInit( | 627 void OnBeforeWidgetInit( |
| 628 views::Widget::InitParams* params, | 628 views::Widget::InitParams* params, |
| 629 views::internal::NativeWidgetDelegate* delegate) override; | 629 views::internal::NativeWidgetDelegate* delegate) override; |
| 630 | 630 |
| 631 private: | 631 private: |
| 632 AppListViewTestDesktop* parent_; | 632 AppListViewTestDesktop* parent_; |
| 633 | 633 |
| 634 DISALLOW_COPY_AND_ASSIGN(AppListViewTestViewsDelegate); | 634 DISALLOW_COPY_AND_ASSIGN(AppListViewTestViewsDelegate); |
| 635 }; | 635 }; |
| 636 | 636 |
| 637 DISALLOW_COPY_AND_ASSIGN(AppListViewTestDesktop); | 637 DISALLOW_COPY_AND_ASSIGN(AppListViewTestDesktop); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 715 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| 716 AppListViewTestAura, | 716 AppListViewTestAura, |
| 717 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 717 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 718 | 718 |
| 719 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 719 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 720 AppListViewTestDesktop, | 720 AppListViewTestDesktop, |
| 721 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 721 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 722 | 722 |
| 723 } // namespace test | 723 } // namespace test |
| 724 } // namespace app_list | 724 } // namespace app_list |
| OLD | NEW |