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

Side by Side Diff: ui/views/controls/menu/menu_model_adapter_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 | « ui/views/controls/menu/menu_message_loop_aura.cc ('k') | ui/views/controls/menu/menu_runner.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 "ui/views/controls/menu/menu_model_adapter.h" 5 #include "ui/views/controls/menu/menu_model_adapter.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/base/models/menu_model.h" 9 #include "ui/base/models/menu_model.h"
10 #include "ui/base/models/menu_model_delegate.h" 10 #include "ui/base/models/menu_model_delegate.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 items_.push_back(Item(TYPE_COMMAND, "command 0", NULL)); 147 items_.push_back(Item(TYPE_COMMAND, "command 0", NULL));
148 items_.push_back(Item(TYPE_CHECK, "check 1", NULL)); 148 items_.push_back(Item(TYPE_CHECK, "check 1", NULL));
149 items_.push_back(Item(TYPE_SEPARATOR, "", NULL)); 149 items_.push_back(Item(TYPE_SEPARATOR, "", NULL));
150 items_.push_back(Item(TYPE_SUBMENU, "submenu 3", submenu_model_.get())); 150 items_.push_back(Item(TYPE_SUBMENU, "submenu 3", submenu_model_.get()));
151 items_.push_back(Item(TYPE_RADIO, "radio 4", NULL)); 151 items_.push_back(Item(TYPE_RADIO, "radio 4", NULL));
152 } 152 }
153 153
154 ~RootModel() override {} 154 ~RootModel() override {}
155 155
156 private: 156 private:
157 scoped_ptr<MenuModel> submenu_model_; 157 std::unique_ptr<MenuModel> submenu_model_;
158 158
159 DISALLOW_COPY_AND_ASSIGN(RootModel); 159 DISALLOW_COPY_AND_ASSIGN(RootModel);
160 }; 160 };
161 161
162 } // namespace 162 } // namespace
163 163
164 namespace views { 164 namespace views {
165 165
166 typedef ViewsTestBase MenuModelAdapterTest; 166 typedef ViewsTestBase MenuModelAdapterTest;
167 167
168 TEST_F(MenuModelAdapterTest, BasicTest) { 168 TEST_F(MenuModelAdapterTest, BasicTest) {
169 // Build model and adapter. 169 // Build model and adapter.
170 RootModel model; 170 RootModel model;
171 views::MenuModelAdapter delegate(&model); 171 views::MenuModelAdapter delegate(&model);
172 172
173 // Create menu. Build menu twice to check that rebuilding works properly. 173 // Create menu. Build menu twice to check that rebuilding works properly.
174 MenuItemView* menu = new views::MenuItemView(&delegate); 174 MenuItemView* menu = new views::MenuItemView(&delegate);
175 // MenuRunner takes ownership of menu. 175 // MenuRunner takes ownership of menu.
176 scoped_ptr<MenuRunner> menu_runner(new MenuRunner(menu, 0)); 176 std::unique_ptr<MenuRunner> menu_runner(new MenuRunner(menu, 0));
177 delegate.BuildMenu(menu); 177 delegate.BuildMenu(menu);
178 delegate.BuildMenu(menu); 178 delegate.BuildMenu(menu);
179 EXPECT_TRUE(menu->HasSubmenu()); 179 EXPECT_TRUE(menu->HasSubmenu());
180 180
181 // Check top level menu items. 181 // Check top level menu items.
182 views::SubmenuView* item_container = menu->GetSubmenu(); 182 views::SubmenuView* item_container = menu->GetSubmenu();
183 EXPECT_EQ(5, item_container->child_count()); 183 EXPECT_EQ(5, item_container->child_count());
184 184
185 for (int i = 0; i < item_container->child_count(); ++i) { 185 for (int i = 0; i < item_container->child_count(); ++i) {
186 const MenuModelBase::Item& model_item = model.GetItemDefinition(i); 186 const MenuModelBase::Item& model_item = model.GetItemDefinition(i);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 submodel->set_last_activation(-1); 267 submodel->set_last_activation(-1);
268 } 268 }
269 269
270 // Check that selecting the root item is safe. The MenuModel does 270 // Check that selecting the root item is safe. The MenuModel does
271 // not care about the root so MenuModelAdapter should do nothing 271 // not care about the root so MenuModelAdapter should do nothing
272 // (not hit the NOTREACHED check) when the root is selected. 272 // (not hit the NOTREACHED check) when the root is selected.
273 static_cast<views::MenuDelegate*>(&delegate)->SelectionChanged(menu); 273 static_cast<views::MenuDelegate*>(&delegate)->SelectionChanged(menu);
274 } 274 }
275 275
276 } // namespace views 276 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_message_loop_aura.cc ('k') | ui/views/controls/menu/menu_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698