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

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

Issue 2870683002: ash: Remove ShelfModel id conversion functions. (Closed)
Patch Set: Address comments. Created 3 years, 7 months 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
« no previous file with comments | « ash/shelf/shelf_view.cc ('k') | chrome/browser/ui/ash/app_list/app_list_controller_ash.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/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 301 }
302 test_api_->RunMessageLoopUntilAnimationsDone(); 302 test_api_->RunMessageLoopUntilAnimationsDone();
303 } 303 }
304 304
305 void RemoveByID(const ShelfID& id) { 305 void RemoveByID(const ShelfID& id) {
306 model_->RemoveItemAt(model_->ItemIndexByID(id)); 306 model_->RemoveItemAt(model_->ItemIndexByID(id));
307 test_api_->RunMessageLoopUntilAnimationsDone(); 307 test_api_->RunMessageLoopUntilAnimationsDone();
308 } 308 }
309 309
310 ShelfButton* GetButtonByID(const ShelfID& id) { 310 ShelfButton* GetButtonByID(const ShelfID& id) {
311 int index = model_->ItemIndexByID(id); 311 return test_api_->GetButton(model_->ItemIndexByID(id));
312 return test_api_->GetButton(index);
313 } 312 }
314 313
315 ShelfItem GetItemByID(const ShelfID& id) { 314 ShelfItem GetItemByID(const ShelfID& id) { return *model_->ItemByID(id); }
316 ShelfItems::const_iterator items = model_->ItemByID(id);
317 return *items;
318 }
319 315
320 void CheckModelIDs( 316 void CheckModelIDs(
321 const std::vector<std::pair<ShelfID, views::View*>>& id_map) { 317 const std::vector<std::pair<ShelfID, views::View*>>& id_map) {
322 size_t map_index = 0; 318 size_t map_index = 0;
323 for (size_t model_index = 0; model_index < model_->items().size(); 319 for (size_t model_index = 0; model_index < model_->items().size();
324 ++model_index) { 320 ++model_index) {
325 ShelfItem item = model_->items()[model_index]; 321 ShelfItem item = model_->items()[model_index];
326 ShelfID id = item.id; 322 ShelfID id = item.id;
327 EXPECT_EQ(id_map[map_index].first, id); 323 EXPECT_EQ(id_map[map_index].first, id);
328 EXPECT_EQ(id_map[map_index].second, GetButtonByID(id)); 324 EXPECT_EQ(id_map[map_index].second, GetButtonByID(id));
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 } 623 }
628 test_api_->HideOverflowBubble(); 624 test_api_->HideOverflowBubble();
629 } 625 }
630 626
631 // Returns the item's ShelfID at |index|. 627 // Returns the item's ShelfID at |index|.
632 ShelfID GetItemId(int index) { 628 ShelfID GetItemId(int index) {
633 DCHECK_GE(index, 0); 629 DCHECK_GE(index, 0);
634 return model_->items()[index].id; 630 return model_->items()[index].id;
635 } 631 }
636 632
637 // Returns the center coordinates for a button. Helper function for an event 633 // Returns the center point of a button. Helper function for event generators.
638 // generator.
639 gfx::Point GetButtonCenter(const ShelfID& button_id) { 634 gfx::Point GetButtonCenter(const ShelfID& button_id) {
640 return GetButtonCenter( 635 return GetButtonCenter(GetButtonByID(button_id));
641 test_api_->GetButton(model_->ItemIndexByID(button_id)));
642 } 636 }
643 637
644 gfx::Point GetButtonCenter(ShelfButton* button) { 638 gfx::Point GetButtonCenter(ShelfButton* button) {
645 return button->GetBoundsInScreen().CenterPoint(); 639 return button->GetBoundsInScreen().CenterPoint();
646 } 640 }
647 641
648 ShelfModel* model_ = nullptr; 642 ShelfModel* model_ = nullptr;
649 ShelfView* shelf_view_ = nullptr; 643 ShelfView* shelf_view_ = nullptr;
650 int browser_index_ = 1; 644 int browser_index_ = 1;
651 bool reach_touch_time_threshold_ = true; 645 bool reach_touch_time_threshold_ = true;
(...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 EXPECT_EQ(views::InkDropState::ACTIVATED, 3111 EXPECT_EQ(views::InkDropState::ACTIVATED,
3118 overflow_button_ink_drop_->GetTargetInkDropState()); 3112 overflow_button_ink_drop_->GetTargetInkDropState());
3119 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 3113 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
3120 IsEmpty()); 3114 IsEmpty());
3121 3115
3122 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 3116 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
3123 } 3117 }
3124 3118
3125 } // namespace test 3119 } // namespace test
3126 } // namespace ash 3120 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.cc ('k') | chrome/browser/ui/ash/app_list/app_list_controller_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698