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

Side by Side Diff: chrome/browser/cocoa/command_observer_bridge_unittest.mm

Issue 178037: Make all of our unit tests be PlatformTests to get an autorelease pool.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/scoped_nsobject.h" 8 #include "base/scoped_nsobject.h"
9 #import "chrome/browser/cocoa/command_observer_bridge.h" 9 #import "chrome/browser/cocoa/command_observer_bridge.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h"
11 12
12 // Implements the callback interface. Records the last command id and 13 // Implements the callback interface. Records the last command id and
13 // enabled state it has received so it can be queried by the tests to see 14 // enabled state it has received so it can be queried by the tests to see
14 // if we got a notification or not. 15 // if we got a notification or not.
15 @interface CommandTestObserver : NSObject<CommandObserverProtocol> { 16 @interface CommandTestObserver : NSObject<CommandObserverProtocol> {
16 @private 17 @private
17 int lastCommand_; // id of last received state change 18 int lastCommand_; // id of last received state change
18 bool lastState_; // state of last received state change 19 bool lastState_; // state of last received state change
19 } 20 }
20 - (int)lastCommand; 21 - (int)lastCommand;
21 - (bool)lastState; 22 - (bool)lastState;
22 @end 23 @end
23 24
24 @implementation CommandTestObserver 25 @implementation CommandTestObserver
25 - (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled { 26 - (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled {
26 lastCommand_ = command; 27 lastCommand_ = command;
27 lastState_ = enabled; 28 lastState_ = enabled;
28 } 29 }
29 - (int)lastCommand { 30 - (int)lastCommand {
30 return lastCommand_; 31 return lastCommand_;
31 } 32 }
32 - (bool)lastState { 33 - (bool)lastState {
33 return lastState_; 34 return lastState_;
34 } 35 }
35 @end 36 @end
36 37
37 namespace { 38 namespace {
38 39
39 class CommandObserverBridgeTest : public testing::Test { 40 class CommandObserverBridgeTest : public PlatformTest {
40 public: 41 public:
41 CommandObserverBridgeTest() 42 CommandObserverBridgeTest()
42 : updater_(new CommandUpdater(NULL)), 43 : updater_(new CommandUpdater(NULL)),
43 observer_([[CommandTestObserver alloc] init]) { 44 observer_([[CommandTestObserver alloc] init]) {
44 } 45 }
45 scoped_ptr<CommandUpdater> updater_; 46 scoped_ptr<CommandUpdater> updater_;
46 scoped_nsobject<CommandTestObserver> observer_; 47 scoped_nsobject<CommandTestObserver> observer_;
47 }; 48 };
48 49
49 // Tests creation and deletion. NULL arguments aren't allowed. 50 // Tests creation and deletion. NULL arguments aren't allowed.
(...skipping 29 matching lines...) Expand all
79 80
80 // Change something we're not watching and make sure the last state hasn't 81 // Change something we're not watching and make sure the last state hasn't
81 // changed. 82 // changed.
82 updater_->UpdateCommandEnabled(3, false); 83 updater_->UpdateCommandEnabled(3, false);
83 EXPECT_EQ([observer_ lastCommand], 1); 84 EXPECT_EQ([observer_ lastCommand], 1);
84 EXPECT_NE([observer_ lastCommand], 3); 85 EXPECT_NE([observer_ lastCommand], 3);
85 EXPECT_EQ([observer_ lastState], true); 86 EXPECT_EQ([observer_ lastState], true);
86 } 87 }
87 88
88 } // namespace 89 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698