| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 MenuController* controller = menu_controller(); | 1297 MenuController* controller = menu_controller(); |
| 1298 controller->SetAsyncRun(true); | 1298 controller->SetAsyncRun(true); |
| 1299 | 1299 |
| 1300 int mouse_event_flags = 0; | 1300 int mouse_event_flags = 0; |
| 1301 MenuItemView* run_result = | 1301 MenuItemView* run_result = |
| 1302 controller->Run(owner(), nullptr, menu_item(), gfx::Rect(), | 1302 controller->Run(owner(), nullptr, menu_item(), gfx::Rect(), |
| 1303 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags); | 1303 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags); |
| 1304 EXPECT_EQ(run_result, nullptr); | 1304 EXPECT_EQ(run_result, nullptr); |
| 1305 TestCancelEvent(); | 1305 TestCancelEvent(); |
| 1306 } | 1306 } |
| 1307 |
| 1308 // Tests that if a menu is ran without a widget, that MenuPreTargetHandler does |
| 1309 // not cause a crash. |
| 1310 TEST_F(MenuControllerTest, RunWithoutWidgetDoesntCrash) { |
| 1311 ExitMenuRun(); |
| 1312 MenuController* controller = menu_controller(); |
| 1313 controller->SetAsyncRun(true); |
| 1314 int mouse_event_flags = 0; |
| 1315 MenuItemView* run_result = |
| 1316 controller->Run(nullptr, nullptr, menu_item(), gfx::Rect(), |
| 1317 MENU_ANCHOR_TOPLEFT, false, false, &mouse_event_flags); |
| 1318 EXPECT_EQ(run_result, nullptr); |
| 1319 } |
| 1320 |
| 1307 #endif // defined(USE_AURA) | 1321 #endif // defined(USE_AURA) |
| 1308 | 1322 |
| 1309 } // namespace test | 1323 } // namespace test |
| 1310 } // namespace views | 1324 } // namespace views |
| OLD | NEW |