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/launcher/launcher.h" | 5 #include "ash/launcher/launcher.h" |
6 #include "ash/launcher/launcher_item_delegate_manager.h" | |
7 #include "ash/shelf/shelf_button.h" | 6 #include "ash/shelf/shelf_button.h" |
| 7 #include "ash/shelf/shelf_item_delegate_manager.h" |
8 #include "ash/shelf/shelf_model.h" | 8 #include "ash/shelf/shelf_model.h" |
9 #include "ash/shelf/shelf_view.h" | 9 #include "ash/shelf/shelf_view.h" |
10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "ash/test/launcher_test_api.h" | 13 #include "ash/test/launcher_test_api.h" |
14 #include "ash/test/shelf_view_test_api.h" | 14 #include "ash/test/shelf_view_test_api.h" |
15 #include "ash/test/test_launcher_item_delegate.h" | 15 #include "ash/test/test_shelf_item_delegate.h" |
16 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
17 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
18 #include "ui/gfx/display.h" | 18 #include "ui/gfx/display.h" |
19 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
20 #include "ui/views/corewm/corewm_switches.h" | 20 #include "ui/views/corewm/corewm_switches.h" |
21 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
23 | 23 |
24 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
25 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
(...skipping 18 matching lines...) Expand all Loading... |
44 virtual void SetUp() { | 44 virtual void SetUp() { |
45 test::AshTestBase::SetUp(); | 45 test::AshTestBase::SetUp(); |
46 | 46 |
47 launcher_ = Launcher::ForPrimaryDisplay(); | 47 launcher_ = Launcher::ForPrimaryDisplay(); |
48 ASSERT_TRUE(launcher_); | 48 ASSERT_TRUE(launcher_); |
49 | 49 |
50 ash::test::LauncherTestAPI test(launcher_); | 50 ash::test::LauncherTestAPI test(launcher_); |
51 shelf_view_ = test.shelf_view(); | 51 shelf_view_ = test.shelf_view(); |
52 shelf_model_ = shelf_view_->model(); | 52 shelf_model_ = shelf_view_->model(); |
53 item_delegate_manager_ = | 53 item_delegate_manager_ = |
54 Shell::GetInstance()->launcher_item_delegate_manager(); | 54 Shell::GetInstance()->shelf_item_delegate_manager(); |
55 | 55 |
56 test_.reset(new ash::test::ShelfViewTestAPI(shelf_view_)); | 56 test_.reset(new ash::test::ShelfViewTestAPI(shelf_view_)); |
57 } | 57 } |
58 | 58 |
59 virtual void TearDown() OVERRIDE { | 59 virtual void TearDown() OVERRIDE { |
60 test::AshTestBase::TearDown(); | 60 test::AshTestBase::TearDown(); |
61 } | 61 } |
62 | 62 |
63 Launcher* launcher() { | 63 Launcher* launcher() { |
64 return launcher_; | 64 return launcher_; |
65 } | 65 } |
66 | 66 |
67 ShelfView* shelf_view() { | 67 ShelfView* shelf_view() { |
68 return shelf_view_; | 68 return shelf_view_; |
69 } | 69 } |
70 | 70 |
71 ShelfModel* shelf_model() { | 71 ShelfModel* shelf_model() { |
72 return shelf_model_; | 72 return shelf_model_; |
73 } | 73 } |
74 | 74 |
75 LauncherItemDelegateManager* item_manager() { | 75 ShelfItemDelegateManager* item_manager() { |
76 return item_delegate_manager_; | 76 return item_delegate_manager_; |
77 } | 77 } |
78 | 78 |
79 ash::test::ShelfViewTestAPI* test_api() { | 79 ash::test::ShelfViewTestAPI* test_api() { |
80 return test_.get(); | 80 return test_.get(); |
81 } | 81 } |
82 | 82 |
83 private: | 83 private: |
84 Launcher* launcher_; | 84 Launcher* launcher_; |
85 ShelfView* shelf_view_; | 85 ShelfView* shelf_view_; |
86 ShelfModel* shelf_model_; | 86 ShelfModel* shelf_model_; |
87 LauncherItemDelegateManager* item_delegate_manager_; | 87 ShelfItemDelegateManager* item_delegate_manager_; |
88 scoped_ptr<ash::test::ShelfViewTestAPI> test_; | 88 scoped_ptr<test::ShelfViewTestAPI> test_; |
89 | 89 |
90 DISALLOW_COPY_AND_ASSIGN(LauncherTest); | 90 DISALLOW_COPY_AND_ASSIGN(LauncherTest); |
91 }; | 91 }; |
92 | 92 |
93 // Confirms that LauncherItem reflects the appropriated state. | 93 // Confirms that LauncherItem reflects the appropriated state. |
94 TEST_F(LauncherTest, StatusReflection) { | 94 TEST_F(LauncherTest, StatusReflection) { |
95 // Initially we have the app list. | 95 // Initially we have the app list. |
96 int button_count = test_api()->GetButtonCount(); | 96 int button_count = test_api()->GetButtonCount(); |
97 | 97 |
98 // Add running platform app. | 98 // Add running platform app. |
(...skipping 15 matching lines...) Expand all Loading... |
114 TEST_F(LauncherTest, checkHoverAfterMenu) { | 114 TEST_F(LauncherTest, checkHoverAfterMenu) { |
115 // Initially we have the app list. | 115 // Initially we have the app list. |
116 int button_count = test_api()->GetButtonCount(); | 116 int button_count = test_api()->GetButtonCount(); |
117 | 117 |
118 // Add running platform app. | 118 // Add running platform app. |
119 LauncherItem item; | 119 LauncherItem item; |
120 item.type = TYPE_PLATFORM_APP; | 120 item.type = TYPE_PLATFORM_APP; |
121 item.status = STATUS_RUNNING; | 121 item.status = STATUS_RUNNING; |
122 int index = shelf_model()->Add(item); | 122 int index = shelf_model()->Add(item); |
123 | 123 |
124 scoped_ptr<LauncherItemDelegate> delegate( | 124 scoped_ptr<ShelfItemDelegate> delegate( |
125 new ash::test::TestLauncherItemDelegate(NULL)); | 125 new test::TestShelfItemDelegate(NULL)); |
126 item_manager()->SetLauncherItemDelegate(shelf_model()->items()[index].id, | 126 item_manager()->SetShelfItemDelegate(shelf_model()->items()[index].id, |
127 delegate.Pass()); | 127 delegate.Pass()); |
128 | 128 |
129 ASSERT_EQ(++button_count, test_api()->GetButtonCount()); | 129 ASSERT_EQ(++button_count, test_api()->GetButtonCount()); |
130 ShelfButton* button = test_api()->GetButton(index); | 130 ShelfButton* button = test_api()->GetButton(index); |
131 button->AddState(ShelfButton::STATE_HOVERED); | 131 button->AddState(ShelfButton::STATE_HOVERED); |
132 button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); | 132 button->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); |
133 EXPECT_FALSE(button->state() & ShelfButton::STATE_HOVERED); | 133 EXPECT_FALSE(button->state() & ShelfButton::STATE_HOVERED); |
134 | 134 |
135 // Remove it. | 135 // Remove it. |
136 shelf_model()->RemoveItemAt(index); | 136 shelf_model()->RemoveItemAt(index); |
137 } | 137 } |
(...skipping 19 matching lines...) Expand all Loading... |
157 | 157 |
158 // Removes the first item in main shelf view. | 158 // Removes the first item in main shelf view. |
159 shelf_model()->RemoveItemAt(shelf_model()->ItemIndexByID(first_item_id)); | 159 shelf_model()->RemoveItemAt(shelf_model()->ItemIndexByID(first_item_id)); |
160 | 160 |
161 // Waits for all transitions to finish and there should be no crash. | 161 // Waits for all transitions to finish and there should be no crash. |
162 test_api()->RunMessageLoopUntilAnimationsDone(); | 162 test_api()->RunMessageLoopUntilAnimationsDone(); |
163 EXPECT_FALSE(launcher()->IsShowingOverflowBubble()); | 163 EXPECT_FALSE(launcher()->IsShowingOverflowBubble()); |
164 } | 164 } |
165 | 165 |
166 } // namespace ash | 166 } // namespace ash |
OLD | NEW |