| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/presenter/app_list_presenter_impl.h" | 5 #include "ui/app_list/presenter/app_list_presenter_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "ui/app_list/presenter/app_list_presenter_delegate_factory.h" | 10 #include "ui/app_list/presenter/app_list_presenter_delegate_factory.h" |
| 11 #include "ui/app_list/presenter/test/app_list_presenter_impl_test_api.h" | 11 #include "ui/app_list/presenter/test/app_list_presenter_impl_test_api.h" |
| 12 #include "ui/app_list/test/app_list_test_view_delegate.h" | 12 #include "ui/app_list/test/app_list_test_view_delegate.h" |
| 13 #include "ui/app_list/views/app_list_view.h" | 13 #include "ui/app_list/views/app_list_view.h" |
| 14 #include "ui/aura/client/focus_client.h" | 14 #include "ui/aura/client/focus_client.h" |
| 15 #include "ui/aura/test/aura_test_base.h" | 15 #include "ui/aura/test/aura_test_base.h" |
| 16 #include "ui/aura/test/test_screen.h" | 16 #include "ui/aura/test/test_screen.h" |
| 17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/views/test/test_views_delegate.h" |
| 18 #include "ui/wm/core/default_activation_client.h" | 19 #include "ui/wm/core/default_activation_client.h" |
| 19 #include "ui/wm/core/window_util.h" | 20 #include "ui/wm/core/window_util.h" |
| 20 | 21 |
| 21 namespace app_list { | 22 namespace app_list { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Test stub for AppListPresenterDelegate | 26 // Test stub for AppListPresenterDelegate |
| 26 class AppListPresenterDelegateTest : public AppListPresenterDelegate { | 27 class AppListPresenterDelegateTest : public AppListPresenterDelegate { |
| 27 public: | 28 public: |
| 28 AppListPresenterDelegateTest(aura::Window* container, | 29 AppListPresenterDelegateTest(aura::Window* container, |
| 29 test::AppListTestViewDelegate* view_delegate) | 30 test::AppListTestViewDelegate* view_delegate) |
| 30 : container_(container), view_delegate_(view_delegate) {} | 31 : container_(container), view_delegate_(view_delegate) {} |
| 31 ~AppListPresenterDelegateTest() override {} | 32 ~AppListPresenterDelegateTest() override {} |
| 32 | 33 |
| 33 bool init_called() const { return init_called_; } | 34 bool init_called() const { return init_called_; } |
| 34 bool on_shown_called() const { return on_shown_called_; } | 35 bool on_shown_called() const { return on_shown_called_; } |
| 35 bool on_dismissed_called() const { return on_dismissed_called_; } | 36 bool on_dismissed_called() const { return on_dismissed_called_; } |
| 36 bool update_bounds_called() const { return update_bounds_called_; } | 37 bool update_bounds_called() const { return update_bounds_called_; } |
| 37 | 38 |
| 38 private: | 39 private: |
| 39 // AppListPresenterDelegate: | 40 // AppListPresenterDelegate: |
| 40 AppListViewDelegate* GetViewDelegate() override { return view_delegate_; } | 41 AppListViewDelegate* GetViewDelegate() override { return view_delegate_; } |
| 41 void Init(AppListView* view, | 42 void Init(AppListView* view, |
| 42 int64_t display_id, | 43 int64_t display_id, |
| 43 int current_apps_page) override { | 44 int current_apps_page) override { |
| 44 init_called_ = true; | 45 init_called_ = true; |
| 45 view_ = view; | 46 view_ = view; |
| 46 view->InitAsFramelessWindow(container_, current_apps_page, | 47 view->InitAsBubble(container_, current_apps_page); |
| 47 gfx::Rect(100, 50, 300, 200)); | |
| 48 } | 48 } |
| 49 void OnShown(int64_t display_id) override { on_shown_called_ = true; } | 49 void OnShown(int64_t display_id) override { on_shown_called_ = true; } |
| 50 void OnDismissed() override { on_dismissed_called_ = true; } | 50 void OnDismissed() override { on_dismissed_called_ = true; } |
| 51 void UpdateBounds() override { update_bounds_called_ = true; } | 51 void UpdateBounds() override { update_bounds_called_ = true; } |
| 52 gfx::Vector2d GetVisibilityAnimationOffset(aura::Window*) override { | 52 gfx::Vector2d GetVisibilityAnimationOffset(aura::Window*) override { |
| 53 return gfx::Vector2d(0, 0); | 53 return gfx::Vector2d(0, 0); |
| 54 } | 54 } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 aura::Window* container_; | 57 aura::Window* container_; |
| 58 test::AppListTestViewDelegate* view_delegate_; | 58 test::AppListTestViewDelegate* view_delegate_; |
| 59 AppListView* view_ = nullptr; | 59 AppListView* view_ = nullptr; |
| 60 bool init_called_ = false; | 60 bool init_called_ = false; |
| 61 bool on_shown_called_ = false; | 61 bool on_shown_called_ = false; |
| 62 bool on_dismissed_called_ = false; | 62 bool on_dismissed_called_ = false; |
| 63 bool update_bounds_called_ = false; | 63 bool update_bounds_called_ = false; |
| 64 views::TestViewsDelegate views_delegate_; |
| 64 | 65 |
| 65 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); | 66 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 // Test fake for AppListPresenterDelegateFactory, creates instances of | 69 // Test fake for AppListPresenterDelegateFactory, creates instances of |
| 69 // AppListPresenterDelegateTest. | 70 // AppListPresenterDelegateTest. |
| 70 class AppListPresenterDelegateFactoryTest | 71 class AppListPresenterDelegateFactoryTest |
| 71 : public AppListPresenterDelegateFactory { | 72 : public AppListPresenterDelegateFactory { |
| 72 public: | 73 public: |
| 73 explicit AppListPresenterDelegateFactoryTest(aura::Window* container) | 74 explicit AppListPresenterDelegateFactoryTest(aura::Window* container) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // app list's widget is destroyed. | 201 // app list's widget is destroyed. |
| 201 TEST_F(AppListPresenterImplTest, WidgetDestroyed) { | 202 TEST_F(AppListPresenterImplTest, WidgetDestroyed) { |
| 202 presenter()->Show(GetDisplayId()); | 203 presenter()->Show(GetDisplayId()); |
| 203 EXPECT_TRUE(presenter()->GetTargetVisibility()); | 204 EXPECT_TRUE(presenter()->GetTargetVisibility()); |
| 204 presenter()->GetView()->GetWidget()->CloseNow(); | 205 presenter()->GetView()->GetWidget()->CloseNow(); |
| 205 EXPECT_FALSE(presenter()->GetTargetVisibility()); | 206 EXPECT_FALSE(presenter()->GetTargetVisibility()); |
| 206 EXPECT_FALSE(delegate()); | 207 EXPECT_FALSE(delegate()); |
| 207 } | 208 } |
| 208 | 209 |
| 209 } // namespace app_list | 210 } // namespace app_list |
| OLD | NEW |