| 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 #import "ui/views/controls/menu/menu_runner_impl_cocoa.h" | 5 #import "ui/views/controls/menu/menu_runner_impl_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // An anchor view should only be added for Native menus. | 202 // An anchor view should only be added for Native menus. |
| 203 if (GetParam() == MenuType::NATIVE) { | 203 if (GetParam() == MenuType::NATIVE) { |
| 204 ASSERT_EQ(2u, [subviews count]); | 204 ASSERT_EQ(2u, [subviews count]); |
| 205 last_anchor_frame_ = [[subviews objectAtIndex:1] frame]; | 205 last_anchor_frame_ = [[subviews objectAtIndex:1] frame]; |
| 206 } else { | 206 } else { |
| 207 EXPECT_EQ(1u, [subviews count]); | 207 EXPECT_EQ(1u, [subviews count]); |
| 208 } | 208 } |
| 209 runner_->Cancel(); | 209 runner_->Cancel(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Run a nested message loop so that async and sync menus can be tested the | 212 // Run a nested run loop so that async and sync menus can be tested the |
| 213 // same way. | 213 // same way. |
| 214 void MaybeRunAsync() { | 214 void MaybeRunAsync() { |
| 215 if (!IsAsync()) | 215 if (!IsAsync()) |
| 216 return; | 216 return; |
| 217 | 217 |
| 218 base::RunLoop run_loop; | 218 base::RunLoop run_loop; |
| 219 quit_closure_ = run_loop.QuitClosure(); | 219 quit_closure_ = run_loop.QuitClosure(); |
| 220 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 220 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 221 FROM_HERE, quit_closure_, TestTimeouts::action_timeout()); | 221 FROM_HERE, quit_closure_, TestTimeouts::action_timeout()); |
| 222 run_loop.Run(); | 222 run_loop.Run(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 EXPECT_EQ(combobox_rect.right(), last_anchor_frame_.origin.x); | 362 EXPECT_EQ(combobox_rect.right(), last_anchor_frame_.origin.x); |
| 363 } | 363 } |
| 364 | 364 |
| 365 INSTANTIATE_TEST_CASE_P(, | 365 INSTANTIATE_TEST_CASE_P(, |
| 366 MenuRunnerCocoaTest, | 366 MenuRunnerCocoaTest, |
| 367 ::testing::Values(MenuType::NATIVE, MenuType::VIEWS), | 367 ::testing::Values(MenuType::NATIVE, MenuType::VIEWS), |
| 368 &MenuTypeToString); | 368 &MenuTypeToString); |
| 369 | 369 |
| 370 } // namespace test | 370 } // namespace test |
| 371 } // namespace views | 371 } // namespace views |
| OLD | NEW |