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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_action_button_interactive_uitest.mm

Issue 2132593002: Remove remaining calls to deprecated MessageLoop methods on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: h264_vt_encoder_unittest.cc Created 4 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/cocoa/extensions/browser_action_button.h" 5 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/callback_helpers.h" 13 #include "base/callback_helpers.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h"
16 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_task_runner_handle.h"
18 #include "chrome/browser/extensions/extension_action_test_util.h" 18 #include "chrome/browser/extensions/extension_action_test_util.h"
19 #include "chrome/browser/extensions/extension_browsertest.h" 19 #include "chrome/browser/extensions/extension_browsertest.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
22 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h" 22 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h"
23 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 23 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
24 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" 24 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h"
25 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" 25 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
26 #import "chrome/browser/ui/cocoa/run_loop_testing.h" 26 #import "chrome/browser/ui/cocoa/run_loop_testing.h"
27 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 27 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return self; 177 return self;
178 } 178 }
179 179
180 - (void)dealloc { 180 - (void)dealloc {
181 [[NSNotificationCenter defaultCenter] removeObserver:self]; 181 [[NSNotificationCenter defaultCenter] removeObserver:self];
182 [super dealloc]; 182 [super dealloc];
183 } 183 }
184 184
185 - (void)menuDidClose:(NSNotification*)notification { 185 - (void)menuDidClose:(NSNotification*)notification {
186 if (!closeClosure_.is_null()) { 186 if (!closeClosure_.is_null()) {
187 base::MessageLoop::current()->PostTask( 187 base::ThreadTaskRunnerHandle::Get()->PostTask(
188 FROM_HERE, base::ResetAndReturn(&closeClosure_)); 188 FROM_HERE, base::ResetAndReturn(&closeClosure_));
189 } 189 }
190 } 190 }
191 191
192 - (void)menuDidOpen:(NSNotification*)notification { 192 - (void)menuDidOpen:(NSNotification*)notification {
193 if (!openClosure_.is_null()) { 193 if (!openClosure_.is_null()) {
194 base::MessageLoop::current()->PostTask( 194 base::ThreadTaskRunnerHandle::Get()->PostTask(
195 FROM_HERE, base::ResetAndReturn(&openClosure_)); 195 FROM_HERE, base::ResetAndReturn(&openClosure_));
196 } 196 }
197 } 197 }
198 198
199 @end 199 @end
200 200
201 class BrowserActionButtonUiTest : public ExtensionBrowserTest { 201 class BrowserActionButtonUiTest : public ExtensionBrowserTest {
202 protected: 202 protected:
203 BrowserActionButtonUiTest() {} 203 BrowserActionButtonUiTest() {}
204 ~BrowserActionButtonUiTest() override {} 204 ~BrowserActionButtonUiTest() override {}
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // ui_controls:: methods don't play nice when there is an open menu (like the 264 // ui_controls:: methods don't play nice when there is an open menu (like the
265 // app menu). Instead, simulate a right click by feeding the event directly to 265 // app menu). Instead, simulate a right click by feeding the event directly to
266 // the button. 266 // the button.
267 NSPoint centerPoint = GetCenterPoint(actionButton); 267 NSPoint centerPoint = GetCenterPoint(actionButton);
268 NSEvent* mouseEvent = cocoa_test_event_utils::RightMouseDownAtPointInWindow( 268 NSEvent* mouseEvent = cocoa_test_event_utils::RightMouseDownAtPointInWindow(
269 centerPoint, [actionButton window]); 269 centerPoint, [actionButton window]);
270 [actionButton rightMouseDown:mouseEvent]; 270 [actionButton rightMouseDown:mouseEvent];
271 271
272 // This should close the app menu. 272 // This should close the app menu.
273 EXPECT_FALSE([appMenuController isMenuOpen]); 273 EXPECT_FALSE([appMenuController isMenuOpen]);
274 base::MessageLoop::current()->PostTask(FROM_HERE, closure); 274 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure);
275 } 275 }
276 276
277 // Verifies that the action is "popped out" of overflow; that is, it is visible 277 // Verifies that the action is "popped out" of overflow; that is, it is visible
278 // on the main bar, and is set as the popped out action on the controlling 278 // on the main bar, and is set as the popped out action on the controlling
279 // ToolbarActionsBar. 279 // ToolbarActionsBar.
280 void CheckActionIsPoppedOut(BrowserActionsController* actionsController, 280 void CheckActionIsPoppedOut(BrowserActionsController* actionsController,
281 BrowserActionButton* actionButton) { 281 BrowserActionButton* actionButton) {
282 EXPECT_EQ([actionsController containerView], [actionButton superview]); 282 EXPECT_EQ([actionsController containerView], [actionButton superview]);
283 EXPECT_EQ([actionButton viewController], 283 EXPECT_EQ([actionButton viewController],
284 [actionsController toolbarActionsBar]->popped_out_action()); 284 [actionsController toolbarActionsBar]->popped_out_action());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 for (NSUInteger j = 0; j < i; ++j) { 428 for (NSUInteger j = 0; j < i; ++j) {
429 EXPECT_FALSE( 429 EXPECT_FALSE(
430 NSContainsRect([[overflowController buttonWithIndex:j] frame], 430 NSContainsRect([[overflowController buttonWithIndex:j] frame],
431 [button frame])) << error_message; 431 [button frame])) << error_message;
432 } 432 }
433 } 433 }
434 434
435 // Close the app menu. 435 // Close the app menu.
436 [appMenuController cancel]; 436 [appMenuController cancel];
437 EXPECT_FALSE([appMenuController isMenuOpen]) << error_message; 437 EXPECT_FALSE([appMenuController isMenuOpen]) << error_message;
438 base::MessageLoop::current()->PostTask(FROM_HERE, closure); 438 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure);
439 } 439 }
440 440
441 // Tests the layout of the overflow container in the app menu. 441 // Tests the layout of the overflow container in the app menu.
442 // Disabled due to crashing flakily, see crbug.com/602203. 442 // Disabled due to crashing flakily, see crbug.com/602203.
443 IN_PROC_BROWSER_TEST_F(BrowserActionButtonUiTest, 443 IN_PROC_BROWSER_TEST_F(BrowserActionButtonUiTest,
444 DISABLED_TestOverflowContainerLayout) { 444 DISABLED_TestOverflowContainerLayout) {
445 // Add a bunch of extensions - enough to trigger multiple rows in the overflow 445 // Add a bunch of extensions - enough to trigger multiple rows in the overflow
446 // menu. 446 // menu.
447 const int kNumExtensions = 12; 447 const int kNumExtensions = 12;
448 for (int i = 0; i < kNumExtensions; ++i) { 448 for (int i = 0; i < kNumExtensions; ++i) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 openAndCloseAppMenu(appMenuController()); 642 openAndCloseAppMenu(appMenuController());
643 643
644 // Move the extension back to the main bar, so an overflow bar is no longer 644 // Move the extension back to the main bar, so an overflow bar is no longer
645 // needed. Then open and close the app menu a couple times. 645 // needed. Then open and close the app menu a couple times.
646 // This tests that the menu properly cleans up after itself when an overflow 646 // This tests that the menu properly cleans up after itself when an overflow
647 // was present, and is no longer (fix for crbug.com/603241). 647 // was present, and is no longer (fix for crbug.com/603241).
648 model()->SetVisibleIconCount(1); 648 model()->SetVisibleIconCount(1);
649 openAndCloseAppMenu(appMenuController()); 649 openAndCloseAppMenu(appMenuController());
650 openAndCloseAppMenu(appMenuController()); 650 openAndCloseAppMenu(appMenuController());
651 } 651 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698