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

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

Issue 2718563008: mash: Use mojo for ShelfItemDelegate and [app] MenuItem. (Closed)
Patch Set: Cleanup; fix ash_shell compile and a couple tests. Created 3 years, 9 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
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/common/shelf/shelf_view.h" 5 #include "ash/common/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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void Reset() { selected_ = false; } 148 void Reset() { selected_ = false; }
149 149
150 void set_item_selected_action(ShelfAction item_selected_action) { 150 void set_item_selected_action(ShelfAction item_selected_action) {
151 item_selected_action_ = item_selected_action; 151 item_selected_action_ = item_selected_action;
152 } 152 }
153 153
154 // Returns true if the delegate was selected. 154 // Returns true if the delegate was selected.
155 bool WasSelected() { return selected_; } 155 bool WasSelected() { return selected_; }
156 156
157 // TestShelfItemDelegate: 157 // TestShelfItemDelegate:
158 ShelfAction ItemSelected(ui::EventType event_type, 158 void ItemSelected(std::unique_ptr<ui::Event> event,
159 int event_flags, 159 int64_t display_id,
160 int64_t display_id, 160 ShelfLaunchSource source,
161 ShelfLaunchSource source) override { 161 const ItemSelectedCallback& callback) override {
162 selected_ = true; 162 selected_ = true;
163 return item_selected_action_; 163 callback.Run(item_selected_action_, MenuItemList());
164 } 164 }
165 165
166 private: 166 private:
167 bool selected_; 167 bool selected_;
168 168
169 // The action returned from ItemSelected(const ui::Event&). 169 // The action reported by ItemSelected.
170 ShelfAction item_selected_action_; 170 ShelfAction item_selected_action_;
171 171
172 DISALLOW_COPY_AND_ASSIGN(ShelfItemSelectionTracker); 172 DISALLOW_COPY_AND_ASSIGN(ShelfItemSelectionTracker);
173 }; 173 };
174 174
175 TEST_F(WmShelfObserverIconTest, AddRemove) { 175 TEST_F(WmShelfObserverIconTest, AddRemove) {
176 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 176 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
177 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 177 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
178 params.bounds = gfx::Rect(0, 0, 200, 200); 178 params.bounds = gfx::Rect(0, 0, 200, 200);
179 params.context = CurrentContext(); 179 params.context = CurrentContext();
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 }; 1972 };
1973 1973
1974 // A ShelfItemDelegate that returns a menu for the shelf item. 1974 // A ShelfItemDelegate that returns a menu for the shelf item.
1975 class ListMenuShelfItemDelegate : public TestShelfItemDelegate { 1975 class ListMenuShelfItemDelegate : public TestShelfItemDelegate {
1976 public: 1976 public:
1977 ListMenuShelfItemDelegate() : TestShelfItemDelegate(nullptr) {} 1977 ListMenuShelfItemDelegate() : TestShelfItemDelegate(nullptr) {}
1978 ~ListMenuShelfItemDelegate() override {} 1978 ~ListMenuShelfItemDelegate() override {}
1979 1979
1980 private: 1980 private:
1981 // TestShelfItemDelegate: 1981 // TestShelfItemDelegate:
1982 ShelfAppMenuItemList GetAppMenuItems(int event_flags) override { 1982 void ItemSelected(std::unique_ptr<ui::Event> event,
1983 ShelfAppMenuItemList items; 1983 int64_t display_id,
1984 base::string16 title = base::ASCIIToUTF16("title"); 1984 ShelfLaunchSource source,
1985 items.push_back(base::MakeUnique<ShelfApplicationMenuItem>(0, title)); 1985 const ItemSelectedCallback& callback) override {
1986 items.push_back(base::MakeUnique<ShelfApplicationMenuItem>(1, title)); 1986 MenuItemList items;
1987 return items; 1987 items.push_back(ash::mojom::MenuItem::New());
James Cook 2017/03/09 01:09:47 These don't need dummy data?
msw 2017/03/10 06:17:57 Nope! The test only cares that a menu shows; empty
1988 items.push_back(ash::mojom::MenuItem::New());
1989 callback.Run(ash::SHELF_ACTION_NONE, std::move(items));
1988 } 1990 }
1989 1991
1990 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); 1992 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate);
1991 }; 1993 };
1992 1994
1993 } // namespace 1995 } // namespace
1994 1996
1995 // Test fixture for testing material design ink drop ripples on shelf. 1997 // Test fixture for testing material design ink drop ripples on shelf.
1996 class ShelfViewInkDropTest : public ShelfViewTest { 1998 class ShelfViewInkDropTest : public ShelfViewTest {
1997 public: 1999 public:
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 IsEmpty()); 2421 IsEmpty());
2420 } 2422 }
2421 2423
2422 // Tests that clicking on a shelf item that shows an app list menu transitions 2424 // Tests that clicking on a shelf item that shows an app list menu transitions
2423 // ink drop state correctly. 2425 // ink drop state correctly.
2424 TEST_F(ShelfViewInkDropTest, ShelfButtonWithMenuPressRelease) { 2426 TEST_F(ShelfViewInkDropTest, ShelfButtonWithMenuPressRelease) {
2425 InitBrowserButtonInkDrop(); 2427 InitBrowserButtonInkDrop();
2426 2428
2427 // Set a delegate for the shelf item that returns an app list menu. 2429 // Set a delegate for the shelf item that returns an app list menu.
2428 ShelfID browser_shelf_id = model_->items()[browser_index_].id; 2430 ShelfID browser_shelf_id = model_->items()[browser_index_].id;
2429 ListMenuShelfItemDelegate* list_menu_delegate = new ListMenuShelfItemDelegate;
2430 model_->SetShelfItemDelegate(browser_shelf_id, 2431 model_->SetShelfItemDelegate(browser_shelf_id,
2431 base::WrapUnique(list_menu_delegate)); 2432 base::MakeUnique<ListMenuShelfItemDelegate>());
2432 2433
2433 views::CustomButton* button = browser_button_; 2434 views::CustomButton* button = browser_button_;
2434 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); 2435 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint();
2435 2436
2436 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, 2437 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location,
2437 mouse_location, ui::EventTimeForNow(), 2438 mouse_location, ui::EventTimeForNow(),
2438 ui::EF_LEFT_MOUSE_BUTTON, 0); 2439 ui::EF_LEFT_MOUSE_BUTTON, 0);
2439 button->OnMousePressed(press_event); 2440 button->OnMousePressed(press_event);
2440 EXPECT_EQ(views::InkDropState::ACTION_PENDING, 2441 EXPECT_EQ(views::InkDropState::ACTION_PENDING,
2441 browser_button_ink_drop_->GetTargetInkDropState()); 2442 browser_button_ink_drop_->GetTargetInkDropState());
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
3007 EXPECT_EQ(views::InkDropState::ACTIVATED, 3008 EXPECT_EQ(views::InkDropState::ACTIVATED,
3008 overflow_button_ink_drop_->GetTargetInkDropState()); 3009 overflow_button_ink_drop_->GetTargetInkDropState());
3009 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 3010 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
3010 IsEmpty()); 3011 IsEmpty());
3011 3012
3012 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 3013 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
3013 } 3014 }
3014 3015
3015 } // namespace test 3016 } // namespace test
3016 } // namespace ash 3017 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698