Chromium Code Reviews| 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/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 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1997 ink_drop_->SetFocused(is_focused); | 1997 ink_drop_->SetFocused(is_focused); |
| 1998 } | 1998 } |
| 1999 | 1999 |
| 2000 std::unique_ptr<views::InkDrop> ink_drop_; | 2000 std::unique_ptr<views::InkDrop> ink_drop_; |
| 2001 std::vector<views::InkDropState> requested_states_; | 2001 std::vector<views::InkDropState> requested_states_; |
| 2002 | 2002 |
| 2003 private: | 2003 private: |
| 2004 DISALLOW_COPY_AND_ASSIGN(InkDropSpy); | 2004 DISALLOW_COPY_AND_ASSIGN(InkDropSpy); |
| 2005 }; | 2005 }; |
| 2006 | 2006 |
| 2007 // A menu model that contains minimum number of items needed for a menu to be | |
| 2008 // shown on a shelf item. | |
| 2009 class TestShelfMenuModel : public ui::SimpleMenuModel, | |
| 2010 public ui::SimpleMenuModel::Delegate { | |
| 2011 public: | |
| 2012 TestShelfMenuModel() : ui::SimpleMenuModel(this) { Build(); } | |
| 2013 ~TestShelfMenuModel() override {} | |
| 2014 | |
| 2015 private: | |
| 2016 void Build() { | |
| 2017 // A menu is expected to have at least 6 items. Three spacing separators, | |
| 2018 // one title, and at least two more items. | |
| 2019 AddSeparator(ui::SPACING_SEPARATOR); | |
| 2020 AddItem(0, base::ASCIIToUTF16("Title")); | |
| 2021 AddSeparator(ui::SPACING_SEPARATOR); | |
| 2022 AddItem(1, base::ASCIIToUTF16("Item 1")); | |
| 2023 AddItem(2, base::ASCIIToUTF16("Item 2")); | |
| 2024 AddSeparator(ui::SPACING_SEPARATOR); | |
| 2025 } | |
| 2026 | |
| 2027 // ui::SimpleMenuModel::Delegate: | |
| 2028 bool IsCommandIdChecked(int command_id) const override { return false; } | |
| 2029 bool IsCommandIdEnabled(int command_id) const override { | |
| 2030 return command_id != 0; | |
| 2031 } | |
| 2032 void ExecuteCommand(int command_id, int event_flags) override {} | |
| 2033 | |
| 2034 DISALLOW_COPY_AND_ASSIGN(TestShelfMenuModel); | |
| 2035 }; | |
| 2036 | |
| 2037 // A ShelfItemDelegate that returns a menu for the shelf item. | 2007 // A ShelfItemDelegate that returns a menu for the shelf item. |
| 2038 class ListMenuShelfItemDelegate : public TestShelfItemDelegate { | 2008 class ListMenuShelfItemDelegate : public TestShelfItemDelegate { |
| 2039 public: | 2009 public: |
| 2040 ListMenuShelfItemDelegate() : TestShelfItemDelegate(nullptr) {} | 2010 ListMenuShelfItemDelegate() : TestShelfItemDelegate(nullptr) {} |
| 2041 ~ListMenuShelfItemDelegate() override {} | 2011 ~ListMenuShelfItemDelegate() override {} |
| 2042 | 2012 |
| 2043 private: | 2013 private: |
| 2044 // TestShelfItemDelegate: | 2014 // TestShelfItemDelegate: |
| 2045 ui::SimpleMenuModel* CreateApplicationMenu(int event_flags) override { | 2015 ShelfApplicationMenuItems GetAppMenuItems(int event_flags) override { |
| 2046 return new TestShelfMenuModel; | 2016 ShelfApplicationMenuItems items; |
| 2017 base::string16 title = base::ASCIIToUTF16("title"); | |
| 2018 items.push_back(base::MakeUnique<ShelfApplicationMenuItem>(title, nullptr)); | |
|
James Cook
2017/02/06 17:30:21
Given the number of times the (title, nullptr) con
msw
2017/02/07 09:12:01
Done, I added a default parameter and updated call
| |
| 2019 items.push_back(base::MakeUnique<ShelfApplicationMenuItem>(title, nullptr)); | |
| 2020 return items; | |
| 2047 } | 2021 } |
| 2048 | 2022 |
| 2049 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); | 2023 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); |
| 2050 }; | 2024 }; |
| 2051 | 2025 |
| 2052 } // namespace | 2026 } // namespace |
| 2053 | 2027 |
| 2054 // Test fixture that forces material design mode in order to test ink drop | 2028 // Test fixture that forces material design mode in order to test ink drop |
| 2055 // ripples on shelf. | 2029 // ripples on shelf. |
| 2056 class ShelfViewInkDropTest : public ShelfViewTest { | 2030 class ShelfViewInkDropTest : public ShelfViewTest { |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3048 EXPECT_EQ(views::InkDropState::ACTIVATED, | 3022 EXPECT_EQ(views::InkDropState::ACTIVATED, |
| 3049 overflow_button_ink_drop_->GetTargetInkDropState()); | 3023 overflow_button_ink_drop_->GetTargetInkDropState()); |
| 3050 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | 3024 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), |
| 3051 IsEmpty()); | 3025 IsEmpty()); |
| 3052 | 3026 |
| 3053 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 3027 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
| 3054 } | 3028 } |
| 3055 | 3029 |
| 3056 } // namespace test | 3030 } // namespace test |
| 3057 } // namespace ash | 3031 } // namespace ash |
| OLD | NEW |