| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 // Extend the regular AppListTestViewDelegate to communicate back to the test | 139 // Extend the regular AppListTestViewDelegate to communicate back to the test |
| 140 // context. Note the test context doesn't simply inherit this, because the | 140 // context. Note the test context doesn't simply inherit this, because the |
| 141 // delegate is owned by the view. | 141 // delegate is owned by the view. |
| 142 class UnitTestViewDelegate : public app_list::test::AppListTestViewDelegate { | 142 class UnitTestViewDelegate : public app_list::test::AppListTestViewDelegate { |
| 143 public: | 143 public: |
| 144 UnitTestViewDelegate(AppListViewTestContext* parent) : parent_(parent) {} | 144 UnitTestViewDelegate(AppListViewTestContext* parent) : parent_(parent) {} |
| 145 | 145 |
| 146 // Overridden from app_list::AppListViewDelegate: | 146 // Overridden from app_list::AppListViewDelegate: |
| 147 virtual bool ShouldCenterWindow() const OVERRIDE { | 147 virtual bool ShouldCenterWindow() const override { |
| 148 return app_list::switches::IsCenteredAppListEnabled(); | 148 return app_list::switches::IsCenteredAppListEnabled(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Overridden from app_list::test::AppListTestViewDelegate: | 151 // Overridden from app_list::test::AppListTestViewDelegate: |
| 152 virtual void ViewClosing() OVERRIDE { parent_->NativeWidgetClosing(); } | 152 virtual void ViewClosing() override { parent_->NativeWidgetClosing(); } |
| 153 | 153 |
| 154 private: | 154 private: |
| 155 AppListViewTestContext* parent_; | 155 AppListViewTestContext* parent_; |
| 156 | 156 |
| 157 DISALLOW_COPY_AND_ASSIGN(UnitTestViewDelegate); | 157 DISALLOW_COPY_AND_ASSIGN(UnitTestViewDelegate); |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 AppListViewTestContext::AppListViewTestContext(int test_type, | 160 AppListViewTestContext::AppListViewTestContext(int test_type, |
| 161 gfx::NativeView parent) | 161 gfx::NativeView parent) |
| 162 : test_type_(static_cast<TestType>(test_type)) { | 162 : test_type_(static_cast<TestType>(test_type)) { |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 Close(); | 556 Close(); |
| 557 } | 557 } |
| 558 | 558 |
| 559 class AppListViewTestAura : public views::ViewsTestBase, | 559 class AppListViewTestAura : public views::ViewsTestBase, |
| 560 public ::testing::WithParamInterface<int> { | 560 public ::testing::WithParamInterface<int> { |
| 561 public: | 561 public: |
| 562 AppListViewTestAura() {} | 562 AppListViewTestAura() {} |
| 563 virtual ~AppListViewTestAura() {} | 563 virtual ~AppListViewTestAura() {} |
| 564 | 564 |
| 565 // testing::Test overrides: | 565 // testing::Test overrides: |
| 566 virtual void SetUp() OVERRIDE { | 566 virtual void SetUp() override { |
| 567 views::ViewsTestBase::SetUp(); | 567 views::ViewsTestBase::SetUp(); |
| 568 | 568 |
| 569 // On Ash (only) the app list is placed into an aura::Window "container", | 569 // On Ash (only) the app list is placed into an aura::Window "container", |
| 570 // which is also used to determine the context. In tests, use the ash root | 570 // which is also used to determine the context. In tests, use the ash root |
| 571 // window as the parent. This only works on aura where the root window is a | 571 // window as the parent. This only works on aura where the root window is a |
| 572 // NativeView as well as a NativeWindow. | 572 // NativeView as well as a NativeWindow. |
| 573 gfx::NativeView container = NULL; | 573 gfx::NativeView container = NULL; |
| 574 #if defined(USE_AURA) | 574 #if defined(USE_AURA) |
| 575 container = GetContext(); | 575 container = GetContext(); |
| 576 #endif | 576 #endif |
| 577 | 577 |
| 578 test_context_.reset(new AppListViewTestContext(GetParam(), container)); | 578 test_context_.reset(new AppListViewTestContext(GetParam(), container)); |
| 579 } | 579 } |
| 580 | 580 |
| 581 virtual void TearDown() OVERRIDE { | 581 virtual void TearDown() override { |
| 582 test_context_.reset(); | 582 test_context_.reset(); |
| 583 views::ViewsTestBase::TearDown(); | 583 views::ViewsTestBase::TearDown(); |
| 584 } | 584 } |
| 585 | 585 |
| 586 protected: | 586 protected: |
| 587 scoped_ptr<AppListViewTestContext> test_context_; | 587 scoped_ptr<AppListViewTestContext> test_context_; |
| 588 | 588 |
| 589 private: | 589 private: |
| 590 DISALLOW_COPY_AND_ASSIGN(AppListViewTestAura); | 590 DISALLOW_COPY_AND_ASSIGN(AppListViewTestAura); |
| 591 }; | 591 }; |
| 592 | 592 |
| 593 class AppListViewTestDesktop : public views::ViewsTestBase, | 593 class AppListViewTestDesktop : public views::ViewsTestBase, |
| 594 public ::testing::WithParamInterface<int> { | 594 public ::testing::WithParamInterface<int> { |
| 595 public: | 595 public: |
| 596 AppListViewTestDesktop() {} | 596 AppListViewTestDesktop() {} |
| 597 virtual ~AppListViewTestDesktop() {} | 597 virtual ~AppListViewTestDesktop() {} |
| 598 | 598 |
| 599 // testing::Test overrides: | 599 // testing::Test overrides: |
| 600 virtual void SetUp() OVERRIDE { | 600 virtual void SetUp() override { |
| 601 set_views_delegate(new AppListViewTestViewsDelegate(this)); | 601 set_views_delegate(new AppListViewTestViewsDelegate(this)); |
| 602 views::ViewsTestBase::SetUp(); | 602 views::ViewsTestBase::SetUp(); |
| 603 test_context_.reset(new AppListViewTestContext(GetParam(), NULL)); | 603 test_context_.reset(new AppListViewTestContext(GetParam(), NULL)); |
| 604 } | 604 } |
| 605 | 605 |
| 606 virtual void TearDown() OVERRIDE { | 606 virtual void TearDown() override { |
| 607 test_context_.reset(); | 607 test_context_.reset(); |
| 608 views::ViewsTestBase::TearDown(); | 608 views::ViewsTestBase::TearDown(); |
| 609 } | 609 } |
| 610 | 610 |
| 611 protected: | 611 protected: |
| 612 scoped_ptr<AppListViewTestContext> test_context_; | 612 scoped_ptr<AppListViewTestContext> test_context_; |
| 613 | 613 |
| 614 private: | 614 private: |
| 615 class AppListViewTestViewsDelegate : public views::TestViewsDelegate { | 615 class AppListViewTestViewsDelegate : public views::TestViewsDelegate { |
| 616 public: | 616 public: |
| 617 AppListViewTestViewsDelegate(AppListViewTestDesktop* parent) | 617 AppListViewTestViewsDelegate(AppListViewTestDesktop* parent) |
| 618 : parent_(parent) {} | 618 : parent_(parent) {} |
| 619 | 619 |
| 620 // Overridden from views::ViewsDelegate: | 620 // Overridden from views::ViewsDelegate: |
| 621 virtual void OnBeforeWidgetInit( | 621 virtual void OnBeforeWidgetInit( |
| 622 views::Widget::InitParams* params, | 622 views::Widget::InitParams* params, |
| 623 views::internal::NativeWidgetDelegate* delegate) OVERRIDE; | 623 views::internal::NativeWidgetDelegate* delegate) override; |
| 624 | 624 |
| 625 private: | 625 private: |
| 626 AppListViewTestDesktop* parent_; | 626 AppListViewTestDesktop* parent_; |
| 627 | 627 |
| 628 DISALLOW_COPY_AND_ASSIGN(AppListViewTestViewsDelegate); | 628 DISALLOW_COPY_AND_ASSIGN(AppListViewTestViewsDelegate); |
| 629 }; | 629 }; |
| 630 | 630 |
| 631 DISALLOW_COPY_AND_ASSIGN(AppListViewTestDesktop); | 631 DISALLOW_COPY_AND_ASSIGN(AppListViewTestDesktop); |
| 632 }; | 632 }; |
| 633 | 633 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 709 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| 710 AppListViewTestAura, | 710 AppListViewTestAura, |
| 711 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 711 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 712 | 712 |
| 713 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 713 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 714 AppListViewTestDesktop, | 714 AppListViewTestDesktop, |
| 715 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 715 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 716 | 716 |
| 717 } // namespace test | 717 } // namespace test |
| 718 } // namespace app_list | 718 } // namespace app_list |
| OLD | NEW |