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

Side by Side Diff: ash/shelf/shelf_view_unittest.cc

Issue 97173003: ash: Rename more Launcher classes to Shelf*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: link chrome Created 7 years 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/shelf/shelf_view.cc ('k') | ash/shell.h » ('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/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_item_delegate_manager.h"
13 #include "ash/launcher/launcher_types.h" 12 #include "ash/launcher/launcher_types.h"
14 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
15 #include "ash/shelf/overflow_bubble.h" 14 #include "ash/shelf/overflow_bubble.h"
16 #include "ash/shelf/overflow_bubble_view.h" 15 #include "ash/shelf/overflow_bubble_view.h"
17 #include "ash/shelf/shelf_button.h" 16 #include "ash/shelf/shelf_button.h"
18 #include "ash/shelf/shelf_icon_observer.h" 17 #include "ash/shelf/shelf_icon_observer.h"
18 #include "ash/shelf/shelf_item_delegate_manager.h"
19 #include "ash/shelf/shelf_layout_manager.h" 19 #include "ash/shelf/shelf_layout_manager.h"
20 #include "ash/shelf/shelf_model.h" 20 #include "ash/shelf/shelf_model.h"
21 #include "ash/shelf/shelf_tooltip_manager.h" 21 #include "ash/shelf/shelf_tooltip_manager.h"
22 #include "ash/shelf/shelf_widget.h" 22 #include "ash/shelf/shelf_widget.h"
23 #include "ash/shell.h" 23 #include "ash/shell.h"
24 #include "ash/shell_window_ids.h" 24 #include "ash/shell_window_ids.h"
25 #include "ash/test/ash_test_base.h" 25 #include "ash/test/ash_test_base.h"
26 #include "ash/test/launcher_test_api.h" 26 #include "ash/test/launcher_test_api.h"
27 #include "ash/test/overflow_bubble_view_test_api.h" 27 #include "ash/test/overflow_bubble_view_test_api.h"
28 #include "ash/test/shelf_view_test_api.h" 28 #include "ash/test/shelf_view_test_api.h"
29 #include "ash/test/shell_test_api.h" 29 #include "ash/test/shell_test_api.h"
30 #include "ash/test/test_launcher_delegate.h" 30 #include "ash/test/test_launcher_delegate.h"
31 #include "ash/test/test_launcher_item_delegate.h" 31 #include "ash/test/test_shelf_item_delegate.h"
32 #include "base/basictypes.h" 32 #include "base/basictypes.h"
33 #include "base/command_line.h" 33 #include "base/command_line.h"
34 #include "base/compiler_specific.h" 34 #include "base/compiler_specific.h"
35 #include "base/memory/scoped_ptr.h" 35 #include "base/memory/scoped_ptr.h"
36 #include "grit/ash_resources.h" 36 #include "grit/ash_resources.h"
37 #include "ui/aura/root_window.h" 37 #include "ui/aura/root_window.h"
38 #include "ui/aura/test/aura_test_base.h" 38 #include "ui/aura/test/aura_test_base.h"
39 #include "ui/aura/test/event_generator.h" 39 #include "ui/aura/test/event_generator.h"
40 #include "ui/aura/window.h" 40 #include "ui/aura/window.h"
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ASSERT_GT(shelf_size.width(), 0); 192 ASSERT_GT(shelf_size.width(), 0);
193 launcher->SetShelfViewBounds(gfx::Rect(shelf_size)); 193 launcher->SetShelfViewBounds(gfx::Rect(shelf_size));
194 // No animation happens for ShelfView bounds change. 194 // No animation happens for ShelfView bounds change.
195 EXPECT_TRUE(observer()->change_notified()); 195 EXPECT_TRUE(observer()->change_notified());
196 observer()->Reset(); 196 observer()->Reset();
197 } 197 }
198 198
199 //////////////////////////////////////////////////////////////////////////////// 199 ////////////////////////////////////////////////////////////////////////////////
200 // ShelfView tests. 200 // ShelfView tests.
201 201
202 // LauncherItemDelegate for ShelfViewTest.OverflowBubbleSize only. 202 // ShelfItemDelegate for ShelfViewTest.OverflowBubbleSize only.
203 // This class should only be used for re-insert test because it cannot handle 203 // This class should only be used for re-insert test because it cannot handle
204 // unpin request. 204 // unpin request.
205 class TestLauncherDelegateForShelfView : public TestLauncherDelegate { 205 class TestLauncherDelegateForShelfView : public TestLauncherDelegate {
206 public: 206 public:
207 explicit TestLauncherDelegateForShelfView(ShelfModel* model) 207 explicit TestLauncherDelegateForShelfView(ShelfModel* model)
208 : TestLauncherDelegate(model) {} 208 : TestLauncherDelegate(model) {}
209 virtual ~TestLauncherDelegateForShelfView() {} 209 virtual ~TestLauncherDelegateForShelfView() {}
210 210
211 // TestLauncherDelegate overrides: 211 // TestLauncherDelegate overrides:
212 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE { 212 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE {
(...skipping 18 matching lines...) Expand all
231 Launcher* launcher = Launcher::ForPrimaryDisplay(); 231 Launcher* launcher = Launcher::ForPrimaryDisplay();
232 shelf_view_ = test::LauncherTestAPI(launcher).shelf_view(); 232 shelf_view_ = test::LauncherTestAPI(launcher).shelf_view();
233 233
234 // The bounds should be big enough for 4 buttons + overflow chevron. 234 // The bounds should be big enough for 4 buttons + overflow chevron.
235 shelf_view_->SetBounds(0, 0, 500, 235 shelf_view_->SetBounds(0, 0, 500,
236 internal::ShelfLayoutManager::GetPreferredShelfSize()); 236 internal::ShelfLayoutManager::GetPreferredShelfSize());
237 237
238 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); 238 test_api_.reset(new ShelfViewTestAPI(shelf_view_));
239 test_api_->SetAnimationDuration(1); // Speeds up animation for test. 239 test_api_->SetAnimationDuration(1); // Speeds up animation for test.
240 240
241 item_manager_ = 241 item_manager_ = ash::Shell::GetInstance()->shelf_item_delegate_manager();
242 ash::Shell::GetInstance()->launcher_item_delegate_manager();
243 DCHECK(item_manager_); 242 DCHECK(item_manager_);
244 243
245 // Add browser shortcut launcher item at index 0 for test. 244 // Add browser shortcut launcher item at index 0 for test.
246 AddBrowserShortcut(); 245 AddBrowserShortcut();
247 } 246 }
248 247
249 virtual void TearDown() OVERRIDE { 248 virtual void TearDown() OVERRIDE {
250 test_api_.reset(); 249 test_api_.reset();
251 AshTestBase::TearDown(); 250 AshTestBase::TearDown();
252 } 251 }
253 252
254 protected: 253 protected:
255 void CreateAndSetLauncherItemDelegateForID(LauncherID id) { 254 void CreateAndSetShelfItemDelegateForID(LauncherID id) {
256 scoped_ptr<LauncherItemDelegate> delegate( 255 scoped_ptr<ShelfItemDelegate> delegate(new TestShelfItemDelegate(NULL));
257 new ash::test::TestLauncherItemDelegate(NULL)); 256 item_manager_->SetShelfItemDelegate(id, delegate.Pass());
258 item_manager_->SetLauncherItemDelegate(id, delegate.Pass());
259 } 257 }
260 258
261 LauncherID AddBrowserShortcut() { 259 LauncherID AddBrowserShortcut() {
262 LauncherItem browser_shortcut; 260 LauncherItem browser_shortcut;
263 browser_shortcut.type = TYPE_BROWSER_SHORTCUT; 261 browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
264 262
265 LauncherID id = model_->next_id(); 263 LauncherID id = model_->next_id();
266 model_->AddAt(browser_index_, browser_shortcut); 264 model_->AddAt(browser_index_, browser_shortcut);
267 CreateAndSetLauncherItemDelegateForID(id); 265 CreateAndSetShelfItemDelegateForID(id);
268 test_api_->RunMessageLoopUntilAnimationsDone(); 266 test_api_->RunMessageLoopUntilAnimationsDone();
269 return id; 267 return id;
270 } 268 }
271 269
272 LauncherID AddAppShortcut() { 270 LauncherID AddAppShortcut() {
273 LauncherItem item; 271 LauncherItem item;
274 item.type = TYPE_APP_SHORTCUT; 272 item.type = TYPE_APP_SHORTCUT;
275 item.status = STATUS_CLOSED; 273 item.status = STATUS_CLOSED;
276 274
277 LauncherID id = model_->next_id(); 275 LauncherID id = model_->next_id();
278 model_->Add(item); 276 model_->Add(item);
279 CreateAndSetLauncherItemDelegateForID(id); 277 CreateAndSetShelfItemDelegateForID(id);
280 test_api_->RunMessageLoopUntilAnimationsDone(); 278 test_api_->RunMessageLoopUntilAnimationsDone();
281 return id; 279 return id;
282 } 280 }
283 281
284 LauncherID AddPanel() { 282 LauncherID AddPanel() {
285 LauncherID id = AddPanelNoWait(); 283 LauncherID id = AddPanelNoWait();
286 test_api_->RunMessageLoopUntilAnimationsDone(); 284 test_api_->RunMessageLoopUntilAnimationsDone();
287 return id; 285 return id;
288 } 286 }
289 287
290 LauncherID AddPlatformAppNoWait() { 288 LauncherID AddPlatformAppNoWait() {
291 LauncherItem item; 289 LauncherItem item;
292 item.type = TYPE_PLATFORM_APP; 290 item.type = TYPE_PLATFORM_APP;
293 item.status = STATUS_RUNNING; 291 item.status = STATUS_RUNNING;
294 292
295 LauncherID id = model_->next_id(); 293 LauncherID id = model_->next_id();
296 model_->Add(item); 294 model_->Add(item);
297 CreateAndSetLauncherItemDelegateForID(id); 295 CreateAndSetShelfItemDelegateForID(id);
298 return id; 296 return id;
299 } 297 }
300 298
301 LauncherID AddPanelNoWait() { 299 LauncherID AddPanelNoWait() {
302 LauncherItem item; 300 LauncherItem item;
303 item.type = TYPE_APP_PANEL; 301 item.type = TYPE_APP_PANEL;
304 item.status = STATUS_RUNNING; 302 item.status = STATUS_RUNNING;
305 303
306 LauncherID id = model_->next_id(); 304 LauncherID id = model_->next_id();
307 model_->Add(item); 305 model_->Add(item);
308 CreateAndSetLauncherItemDelegateForID(id); 306 CreateAndSetShelfItemDelegateForID(id);
309 return id; 307 return id;
310 } 308 }
311 309
312 LauncherID AddPlatformApp() { 310 LauncherID AddPlatformApp() {
313 LauncherID id = AddPlatformAppNoWait(); 311 LauncherID id = AddPlatformAppNoWait();
314 test_api_->RunMessageLoopUntilAnimationsDone(); 312 test_api_->RunMessageLoopUntilAnimationsDone();
315 return id; 313 return id;
316 } 314 }
317 315
318 void RemoveByID(LauncherID id) { 316 void RemoveByID(LauncherID id) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 return shelf_view_->tooltip_manager()->anchor_; 417 return shelf_view_->tooltip_manager()->anchor_;
420 } 418 }
421 419
422 void ShowTooltip() { 420 void ShowTooltip() {
423 shelf_view_->tooltip_manager()->ShowInternal(); 421 shelf_view_->tooltip_manager()->ShowInternal();
424 } 422 }
425 423
426 ShelfModel* model_; 424 ShelfModel* model_;
427 internal::ShelfView* shelf_view_; 425 internal::ShelfView* shelf_view_;
428 int browser_index_; 426 int browser_index_;
429 LauncherItemDelegateManager* item_manager_; 427 ShelfItemDelegateManager* item_manager_;
430 428
431 scoped_ptr<ShelfViewTestAPI> test_api_; 429 scoped_ptr<ShelfViewTestAPI> test_api_;
432 430
433 private: 431 private:
434 DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); 432 DISALLOW_COPY_AND_ASSIGN(ShelfViewTest);
435 }; 433 };
436 434
437 class ShelfViewLegacyShelfLayoutTest : public ShelfViewTest { 435 class ShelfViewLegacyShelfLayoutTest : public ShelfViewTest {
438 public: 436 public:
439 ShelfViewLegacyShelfLayoutTest() : ShelfViewTest() { 437 ShelfViewLegacyShelfLayoutTest() : ShelfViewTest() {
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 test_api_->RunMessageLoopUntilAnimationsDone(); 1595 test_api_->RunMessageLoopUntilAnimationsDone();
1598 CheckAllItemsAreInBounds(); 1596 CheckAllItemsAreInBounds();
1599 } 1597 }
1600 1598
1601 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); 1599 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool());
1602 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, 1600 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest,
1603 testing::Bool()); 1601 testing::Bool());
1604 1602
1605 } // namespace test 1603 } // namespace test
1606 } // namespace ash 1604 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.cc ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698