Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: ash/launcher/launcher_unittest.cc

Issue 71653003: ash: Rename LauncherModel to ShelfModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chrome changes Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/launcher/launcher_model_unittest.cc ('k') | ash/shelf/app_list_shelf_item_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_button.h" 6 #include "ash/launcher/launcher_button.h"
7 #include "ash/launcher/launcher_item_delegate_manager.h" 7 #include "ash/launcher/launcher_item_delegate_manager.h"
8 #include "ash/launcher/launcher_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_launcher_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"
26 #endif 26 #endif
27 27
28 typedef ash::test::AshTestBase LauncherTest; 28 typedef ash::test::AshTestBase LauncherTest;
29 using ash::internal::ShelfView; 29 using ash::internal::ShelfView;
30 using ash::internal::LauncherButton; 30 using ash::internal::LauncherButton;
31 31
32 namespace ash { 32 namespace ash {
33 33
34 class LauncherTest : public ash::test::AshTestBase { 34 class LauncherTest : public ash::test::AshTestBase {
35 public: 35 public:
36 LauncherTest() : launcher_(NULL), 36 LauncherTest() : launcher_(NULL),
37 shelf_view_(NULL), 37 shelf_view_(NULL),
38 launcher_model_(NULL), 38 shelf_model_(NULL),
39 item_delegate_manager_(NULL) { 39 item_delegate_manager_(NULL) {
40 } 40 }
41 41
42 virtual ~LauncherTest() {} 42 virtual ~LauncherTest() {}
43 43
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 launcher_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()->launcher_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 LauncherModel* launcher_model() { 71 ShelfModel* shelf_model() {
72 return launcher_model_; 72 return shelf_model_;
73 } 73 }
74 74
75 LauncherItemDelegateManager* item_manager() { 75 LauncherItemDelegateManager* 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 LauncherModel* launcher_model_; 86 ShelfModel* shelf_model_;
87 LauncherItemDelegateManager* item_delegate_manager_; 87 LauncherItemDelegateManager* item_delegate_manager_;
88 scoped_ptr<ash::test::ShelfViewTestAPI> test_; 88 scoped_ptr<ash::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.
99 LauncherItem item; 99 LauncherItem item;
100 item.type = TYPE_PLATFORM_APP; 100 item.type = TYPE_PLATFORM_APP;
101 item.status = STATUS_RUNNING; 101 item.status = STATUS_RUNNING;
102 int index = launcher_model()->Add(item); 102 int index = shelf_model()->Add(item);
103 ASSERT_EQ(++button_count, test_api()->GetButtonCount()); 103 ASSERT_EQ(++button_count, test_api()->GetButtonCount());
104 LauncherButton* button = test_api()->GetButton(index); 104 LauncherButton* button = test_api()->GetButton(index);
105 EXPECT_EQ(LauncherButton::STATE_RUNNING, button->state()); 105 EXPECT_EQ(LauncherButton::STATE_RUNNING, button->state());
106 106
107 // Remove it. 107 // Remove it.
108 launcher_model()->RemoveItemAt(index); 108 shelf_model()->RemoveItemAt(index);
109 ASSERT_EQ(--button_count, test_api()->GetButtonCount()); 109 ASSERT_EQ(--button_count, test_api()->GetButtonCount());
110 } 110 }
111 111
112 // Confirm that using the menu will clear the hover attribute. To avoid another 112 // Confirm that using the menu will clear the hover attribute. To avoid another
113 // browser test we check this here. 113 // browser test we check this here.
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 = launcher_model()->Add(item); 122 int index = shelf_model()->Add(item);
123 123
124 scoped_ptr<LauncherItemDelegate> delegate( 124 scoped_ptr<LauncherItemDelegate> delegate(
125 new ash::test::TestLauncherItemDelegate(NULL)); 125 new ash::test::TestLauncherItemDelegate(NULL));
126 item_manager()->SetLauncherItemDelegate(launcher_model()->items()[index].id, 126 item_manager()->SetLauncherItemDelegate(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 LauncherButton* button = test_api()->GetButton(index); 130 LauncherButton* button = test_api()->GetButton(index);
131 button->AddState(LauncherButton::STATE_HOVERED); 131 button->AddState(LauncherButton::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() & LauncherButton::STATE_HOVERED); 133 EXPECT_FALSE(button->state() & LauncherButton::STATE_HOVERED);
134 134
135 // Remove it. 135 // Remove it.
136 launcher_model()->RemoveItemAt(index); 136 shelf_model()->RemoveItemAt(index);
137 } 137 }
138 138
139 TEST_F(LauncherTest, ShowOverflowBubble) { 139 TEST_F(LauncherTest, ShowOverflowBubble) {
140 LauncherID first_item_id = launcher_model()->next_id(); 140 LauncherID first_item_id = shelf_model()->next_id();
141 141
142 // Add platform app button until overflow. 142 // Add platform app button until overflow.
143 int items_added = 0; 143 int items_added = 0;
144 while (!test_api()->IsOverflowButtonVisible()) { 144 while (!test_api()->IsOverflowButtonVisible()) {
145 LauncherItem item; 145 LauncherItem item;
146 item.type = TYPE_PLATFORM_APP; 146 item.type = TYPE_PLATFORM_APP;
147 item.status = STATUS_RUNNING; 147 item.status = STATUS_RUNNING;
148 launcher_model()->Add(item); 148 shelf_model()->Add(item);
149 149
150 ++items_added; 150 ++items_added;
151 ASSERT_LT(items_added, 10000); 151 ASSERT_LT(items_added, 10000);
152 } 152 }
153 153
154 // Shows overflow bubble. 154 // Shows overflow bubble.
155 test_api()->ShowOverflowBubble(); 155 test_api()->ShowOverflowBubble();
156 EXPECT_TRUE(launcher()->IsShowingOverflowBubble()); 156 EXPECT_TRUE(launcher()->IsShowingOverflowBubble());
157 157
158 // Removes the first item in main shelf view. 158 // Removes the first item in main shelf view.
159 launcher_model()->RemoveItemAt( 159 shelf_model()->RemoveItemAt(shelf_model()->ItemIndexByID(first_item_id));
160 launcher_model()->ItemIndexByID(first_item_id));
161 160
162 // 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.
163 test_api()->RunMessageLoopUntilAnimationsDone(); 162 test_api()->RunMessageLoopUntilAnimationsDone();
164 EXPECT_FALSE(launcher()->IsShowingOverflowBubble()); 163 EXPECT_FALSE(launcher()->IsShowingOverflowBubble());
165 } 164 }
166 165
167 } // namespace ash 166 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher_model_unittest.cc ('k') | ash/shelf/app_list_shelf_item_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698