| 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 "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/test/base/interactive_test_utils.h" | 7 #include "chrome/test/base/interactive_test_utils.h" |
| 8 #include "chrome/test/base/ui_test_utils.h" | 8 #include "chrome/test/base/ui_test_utils.h" |
| 9 #include "chrome/test/base/view_event_test_base.h" | 9 #include "chrome/test/base/view_event_test_base.h" |
| 10 #include "ui/base/models/menu_model.h" | 10 #include "ui/base/models/menu_model.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 virtual gfx::Size GetPreferredSize() OVERRIDE { | 228 virtual gfx::Size GetPreferredSize() OVERRIDE { |
| 229 return button_->GetPreferredSize(); | 229 return button_->GetPreferredSize(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 // views::MenuButtonListener implementation. | 232 // views::MenuButtonListener implementation. |
| 233 virtual void OnMenuButtonClicked(views::View* source, | 233 virtual void OnMenuButtonClicked(views::View* source, |
| 234 const gfx::Point& point) OVERRIDE { | 234 const gfx::Point& point) OVERRIDE { |
| 235 gfx::Point screen_location; | 235 gfx::Point screen_location; |
| 236 views::View::ConvertPointToScreen(source, &screen_location); | 236 views::View::ConvertPointToScreen(source, &screen_location); |
| 237 gfx::Rect bounds(screen_location, source->size()); | 237 gfx::Rect bounds(screen_location, source->size()); |
| 238 ignore_result(menu_runner_->RunMenuAt( | 238 ignore_result(menu_runner_->RunMenuAt(source->GetWidget(), |
| 239 source->GetWidget(), | 239 button_, |
| 240 button_, | 240 bounds, |
| 241 bounds, | 241 ui::MENU_ANCHOR_TOPLEFT, |
| 242 views::MenuItemView::TOPLEFT, | 242 ui::MENU_SOURCE_NONE, |
| 243 ui::MENU_SOURCE_NONE, | 243 views::MenuRunner::HAS_MNEMONICS)); |
| 244 views::MenuRunner::HAS_MNEMONICS)); | |
| 245 } | 244 } |
| 246 | 245 |
| 247 // ViewEventTestBase implementation | 246 // ViewEventTestBase implementation |
| 248 virtual void DoTestOnMessageLoop() OVERRIDE { | 247 virtual void DoTestOnMessageLoop() OVERRIDE { |
| 249 Click(button_, CreateEventTask(this, &MenuModelAdapterTest::Step1)); | 248 Click(button_, CreateEventTask(this, &MenuModelAdapterTest::Step1)); |
| 250 } | 249 } |
| 251 | 250 |
| 252 // Open the submenu. | 251 // Open the submenu. |
| 253 void Step1() { | 252 void Step1() { |
| 254 views::SubmenuView* topmenu = menu_->GetSubmenu(); | 253 views::SubmenuView* topmenu = menu_->GetSubmenu(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 views::TestViewsDelegate views_delegate_; | 310 views::TestViewsDelegate views_delegate_; |
| 312 | 311 |
| 313 views::MenuButton* button_; | 312 views::MenuButton* button_; |
| 314 TopMenuModel top_menu_model_; | 313 TopMenuModel top_menu_model_; |
| 315 views::MenuModelAdapter menu_model_adapter_; | 314 views::MenuModelAdapter menu_model_adapter_; |
| 316 views::MenuItemView* menu_; | 315 views::MenuItemView* menu_; |
| 317 scoped_ptr<views::MenuRunner> menu_runner_; | 316 scoped_ptr<views::MenuRunner> menu_runner_; |
| 318 }; | 317 }; |
| 319 | 318 |
| 320 VIEW_TEST(MenuModelAdapterTest, RebuildMenu) | 319 VIEW_TEST(MenuModelAdapterTest, RebuildMenu) |
| OLD | NEW |