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

Side by Side Diff: chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller_unittest.mm

Issue 7712008: Refactor and clean up code now that chrome::testing::NSRunLoopRunAllPending() exists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update gtest_exclude Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_nsobject.h" 5 #include "base/memory/scoped_nsobject.h"
6 #include "chrome/app/chrome_command_ids.h" 6 #include "chrome/app/chrome_command_ids.h"
7 #include "chrome/browser/ui/cocoa/browser_test_helper.h" 7 #include "chrome/browser/ui/cocoa/browser_test_helper.h"
8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
9 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 9 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
10 #include "chrome/browser/ui/cocoa/run_loop_testing.h"
10 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" 11 #import "chrome/browser/ui/cocoa/view_resizer_pong.h"
11 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" 12 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h"
12 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 13 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "testing/platform_test.h" 16 #include "testing/platform_test.h"
16 17
17 // Override to avoid dealing with run loops in the testing environment.
18 @implementation WrenchMenuController (UnitTesting)
19 - (void)dispatchCommandInternal:(NSInteger)tag {
20 [self wrenchMenuModel]->ExecuteCommand(tag);
21 }
22 @end
23
24
25 namespace { 18 namespace {
26 19
27 class MockWrenchMenuModel : public WrenchMenuModel { 20 class MockWrenchMenuModel : public WrenchMenuModel {
28 public: 21 public:
29 MockWrenchMenuModel() : WrenchMenuModel() {} 22 MockWrenchMenuModel() : WrenchMenuModel() {}
30 ~MockWrenchMenuModel() { 23 ~MockWrenchMenuModel() {
31 // This dirty, ugly hack gets around a bug in the test. In 24 // This dirty, ugly hack gets around a bug in the test. In
32 // ~WrenchMenuModel(), there's a call to TabstripModel::RemoveObserver(this) 25 // ~WrenchMenuModel(), there's a call to TabstripModel::RemoveObserver(this)
33 // which mysteriously leads to this crash: http://crbug.com/49206 . It 26 // which mysteriously leads to this crash: http://crbug.com/49206 . It
34 // seems that the vector of observers is getting hosed somewhere between 27 // seems that the vector of observers is getting hosed somewhere between
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 65
73 TEST_F(WrenchMenuControllerTest, DispatchSimple) { 66 TEST_F(WrenchMenuControllerTest, DispatchSimple) {
74 scoped_nsobject<NSButton> button([[NSButton alloc] init]); 67 scoped_nsobject<NSButton> button([[NSButton alloc] init]);
75 [button setTag:IDC_ZOOM_PLUS]; 68 [button setTag:IDC_ZOOM_PLUS];
76 69
77 // Set fake model to test dispatching. 70 // Set fake model to test dispatching.
78 EXPECT_CALL(fake_model_, ExecuteCommand(IDC_ZOOM_PLUS)); 71 EXPECT_CALL(fake_model_, ExecuteCommand(IDC_ZOOM_PLUS));
79 [controller() setModel:&fake_model_]; 72 [controller() setModel:&fake_model_];
80 73
81 [controller() dispatchWrenchMenuCommand:button.get()]; 74 [controller() dispatchWrenchMenuCommand:button.get()];
75 chrome::testing::NSRunLoopRunAllPending();
82 } 76 }
83 77
84 } // namespace 78 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698