| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/launcher/launcher.h" | 11 #include "ash/launcher/launcher.h" |
| 12 #include "ash/launcher/launcher_button.h" | 12 #include "ash/launcher/launcher_button.h" |
| 13 #include "ash/launcher/launcher_icon_observer.h" | |
| 14 #include "ash/launcher/launcher_item_delegate_manager.h" | 13 #include "ash/launcher/launcher_item_delegate_manager.h" |
| 15 #include "ash/launcher/launcher_model.h" | 14 #include "ash/launcher/launcher_model.h" |
| 16 #include "ash/launcher/launcher_types.h" | 15 #include "ash/launcher/launcher_types.h" |
| 17 #include "ash/root_window_controller.h" | 16 #include "ash/root_window_controller.h" |
| 17 #include "ash/shelf/shelf_icon_observer.h" |
| 18 #include "ash/shelf/shelf_layout_manager.h" | 18 #include "ash/shelf/shelf_layout_manager.h" |
| 19 #include "ash/shelf/shelf_tooltip_manager.h" | 19 #include "ash/shelf/shelf_tooltip_manager.h" |
| 20 #include "ash/shelf/shelf_widget.h" | 20 #include "ash/shelf/shelf_widget.h" |
| 21 #include "ash/shell.h" | 21 #include "ash/shell.h" |
| 22 #include "ash/shell_window_ids.h" | 22 #include "ash/shell_window_ids.h" |
| 23 #include "ash/test/ash_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
| 24 #include "ash/test/launcher_test_api.h" | 24 #include "ash/test/launcher_test_api.h" |
| 25 #include "ash/test/shelf_view_test_api.h" | 25 #include "ash/test/shelf_view_test_api.h" |
| 26 #include "ash/test/shell_test_api.h" | 26 #include "ash/test/shell_test_api.h" |
| 27 #include "ash/test/test_launcher_delegate.h" | 27 #include "ash/test/test_launcher_delegate.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 #include "ui/events/event.h" | 40 #include "ui/events/event.h" |
| 41 #include "ui/events/event_constants.h" | 41 #include "ui/events/event_constants.h" |
| 42 #include "ui/views/view_model.h" | 42 #include "ui/views/view_model.h" |
| 43 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
| 44 #include "ui/views/widget/widget_delegate.h" | 44 #include "ui/views/widget/widget_delegate.h" |
| 45 | 45 |
| 46 namespace ash { | 46 namespace ash { |
| 47 namespace test { | 47 namespace test { |
| 48 | 48 |
| 49 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
| 50 // LauncherIconObserver tests. | 50 // ShelfIconObserver tests. |
| 51 | 51 |
| 52 class TestLauncherIconObserver : public LauncherIconObserver { | 52 class TestShelfIconObserver : public ShelfIconObserver { |
| 53 public: | 53 public: |
| 54 explicit TestLauncherIconObserver(Launcher* launcher) | 54 explicit TestShelfIconObserver(Launcher* launcher) |
| 55 : launcher_(launcher), | 55 : launcher_(launcher), |
| 56 change_notified_(false) { | 56 change_notified_(false) { |
| 57 if (launcher_) | 57 if (launcher_) |
| 58 launcher_->AddIconObserver(this); | 58 launcher_->AddIconObserver(this); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual ~TestLauncherIconObserver() { | 61 virtual ~TestShelfIconObserver() { |
| 62 if (launcher_) | 62 if (launcher_) |
| 63 launcher_->RemoveIconObserver(this); | 63 launcher_->RemoveIconObserver(this); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // LauncherIconObserver implementation. | 66 // ShelfIconObserver implementation. |
| 67 virtual void OnLauncherIconPositionsChanged() OVERRIDE { | 67 virtual void OnShelfIconPositionsChanged() OVERRIDE { |
| 68 change_notified_ = true; | 68 change_notified_ = true; |
| 69 } | 69 } |
| 70 | 70 |
| 71 int change_notified() const { return change_notified_; } | 71 int change_notified() const { return change_notified_; } |
| 72 void Reset() { change_notified_ = false; } | 72 void Reset() { change_notified_ = false; } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 Launcher* launcher_; | 75 Launcher* launcher_; |
| 76 bool change_notified_; | 76 bool change_notified_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(TestLauncherIconObserver); | 78 DISALLOW_COPY_AND_ASSIGN(TestShelfIconObserver); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class ShelfViewIconObserverTest : public ash::test::AshTestBase { | 81 class ShelfViewIconObserverTest : public ash::test::AshTestBase { |
| 82 public: | 82 public: |
| 83 ShelfViewIconObserverTest() {} | 83 ShelfViewIconObserverTest() {} |
| 84 virtual ~ShelfViewIconObserverTest() {} | 84 virtual ~ShelfViewIconObserverTest() {} |
| 85 | 85 |
| 86 virtual void SetUp() OVERRIDE { | 86 virtual void SetUp() OVERRIDE { |
| 87 AshTestBase::SetUp(); | 87 AshTestBase::SetUp(); |
| 88 Launcher* launcher = Launcher::ForPrimaryDisplay(); | 88 Launcher* launcher = Launcher::ForPrimaryDisplay(); |
| 89 observer_.reset(new TestLauncherIconObserver(launcher)); | 89 observer_.reset(new TestShelfIconObserver(launcher)); |
| 90 | 90 |
| 91 shelf_view_test_.reset(new ShelfViewTestAPI( | 91 shelf_view_test_.reset(new ShelfViewTestAPI( |
| 92 LauncherTestAPI(launcher).shelf_view())); | 92 LauncherTestAPI(launcher).shelf_view())); |
| 93 shelf_view_test_->SetAnimationDuration(1); | 93 shelf_view_test_->SetAnimationDuration(1); |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void TearDown() OVERRIDE { | 96 virtual void TearDown() OVERRIDE { |
| 97 observer_.reset(); | 97 observer_.reset(); |
| 98 AshTestBase::TearDown(); | 98 AshTestBase::TearDown(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TestLauncherIconObserver* observer() { return observer_.get(); } | 101 TestShelfIconObserver* observer() { return observer_.get(); } |
| 102 | 102 |
| 103 ShelfViewTestAPI* shelf_view_test() { | 103 ShelfViewTestAPI* shelf_view_test() { |
| 104 return shelf_view_test_.get(); | 104 return shelf_view_test_.get(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 Launcher* LauncherForSecondaryDisplay() { | 107 Launcher* LauncherForSecondaryDisplay() { |
| 108 return Launcher::ForWindow(Shell::GetAllRootWindows()[1]); | 108 return Launcher::ForWindow(Shell::GetAllRootWindows()[1]); |
| 109 } | 109 } |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 scoped_ptr<TestLauncherIconObserver> observer_; | 112 scoped_ptr<TestShelfIconObserver> observer_; |
| 113 scoped_ptr<ShelfViewTestAPI> shelf_view_test_; | 113 scoped_ptr<ShelfViewTestAPI> shelf_view_test_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(ShelfViewIconObserverTest); | 115 DISALLOW_COPY_AND_ASSIGN(ShelfViewIconObserverTest); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 TEST_F(ShelfViewIconObserverTest, AddRemove) { | 118 TEST_F(ShelfViewIconObserverTest, AddRemove) { |
| 119 ash::test::TestLauncherDelegate* launcher_delegate = | 119 ash::test::TestLauncherDelegate* launcher_delegate = |
| 120 ash::test::TestLauncherDelegate::instance(); | 120 ash::test::TestLauncherDelegate::instance(); |
| 121 ASSERT_TRUE(launcher_delegate); | 121 ASSERT_TRUE(launcher_delegate); |
| 122 | 122 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 144 #define MAYBE_AddRemoveWithMultipleDisplays \ | 144 #define MAYBE_AddRemoveWithMultipleDisplays \ |
| 145 DISABLED_AddRemoveWithMultipleDisplays | 145 DISABLED_AddRemoveWithMultipleDisplays |
| 146 #else | 146 #else |
| 147 #define MAYBE_AddRemoveWithMultipleDisplays \ | 147 #define MAYBE_AddRemoveWithMultipleDisplays \ |
| 148 AddRemoveWithMultipleDisplays | 148 AddRemoveWithMultipleDisplays |
| 149 #endif | 149 #endif |
| 150 // Make sure creating/deleting an window on one displays notifies a | 150 // Make sure creating/deleting an window on one displays notifies a |
| 151 // launcher on external display as well as one on primary. | 151 // launcher on external display as well as one on primary. |
| 152 TEST_F(ShelfViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { | 152 TEST_F(ShelfViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { |
| 153 UpdateDisplay("400x400,400x400"); | 153 UpdateDisplay("400x400,400x400"); |
| 154 TestLauncherIconObserver second_observer(LauncherForSecondaryDisplay()); | 154 TestShelfIconObserver second_observer(LauncherForSecondaryDisplay()); |
| 155 | 155 |
| 156 ash::test::TestLauncherDelegate* launcher_delegate = | 156 ash::test::TestLauncherDelegate* launcher_delegate = |
| 157 ash::test::TestLauncherDelegate::instance(); | 157 ash::test::TestLauncherDelegate::instance(); |
| 158 ASSERT_TRUE(launcher_delegate); | 158 ASSERT_TRUE(launcher_delegate); |
| 159 | 159 |
| 160 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 160 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 161 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 161 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 162 params.bounds = gfx::Rect(0, 0, 200, 200); | 162 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 163 params.context = CurrentContext(); | 163 params.context = CurrentContext(); |
| 164 | 164 |
| (...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 test_api_->RunMessageLoopUntilAnimationsDone(); | 1372 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1373 CheckAllItemsAreInBounds(); | 1373 CheckAllItemsAreInBounds(); |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1376 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
| 1377 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1377 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
| 1378 testing::Bool()); | 1378 testing::Bool()); |
| 1379 | 1379 |
| 1380 } // namespace test | 1380 } // namespace test |
| 1381 } // namespace ash | 1381 } // namespace ash |
| OLD | NEW |