OLD | NEW |
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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/command_updater.h" | 9 #include "chrome/browser/command_updater.h" |
10 #import "chrome/browser/ui/cocoa/command_observer_bridge.h" | 10 #import "chrome/browser/ui/cocoa/command_observer_bridge.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "testing/platform_test.h" | 12 #include "testing/platform_test.h" |
13 | 13 |
14 // Implements the callback interface. Records the last command id and | 14 // Implements the callback interface. Records the last command id and |
15 // enabled state it has received so it can be queried by the tests to see | 15 // enabled state it has received so it can be queried by the tests to see |
16 // if we got a notification or not. | 16 // if we got a notification or not. |
17 @interface CommandTestObserver : NSObject<CommandObserverProtocol> { | 17 @interface CommandTestObserver : NSObject<CommandObserverProtocol> { |
(...skipping 20 matching lines...) Expand all Loading... |
38 | 38 |
39 namespace { | 39 namespace { |
40 | 40 |
41 class CommandObserverBridgeTest : public PlatformTest { | 41 class CommandObserverBridgeTest : public PlatformTest { |
42 public: | 42 public: |
43 CommandObserverBridgeTest() | 43 CommandObserverBridgeTest() |
44 : updater_(new CommandUpdater(NULL)), | 44 : updater_(new CommandUpdater(NULL)), |
45 observer_([[CommandTestObserver alloc] init]) { | 45 observer_([[CommandTestObserver alloc] init]) { |
46 } | 46 } |
47 scoped_ptr<CommandUpdater> updater_; | 47 scoped_ptr<CommandUpdater> updater_; |
48 scoped_nsobject<CommandTestObserver> observer_; | 48 base::scoped_nsobject<CommandTestObserver> observer_; |
49 }; | 49 }; |
50 | 50 |
51 // Tests creation and deletion. NULL arguments aren't allowed. | 51 // Tests creation and deletion. NULL arguments aren't allowed. |
52 TEST_F(CommandObserverBridgeTest, Create) { | 52 TEST_F(CommandObserverBridgeTest, Create) { |
53 CommandObserverBridge bridge(observer_.get(), updater_.get()); | 53 CommandObserverBridge bridge(observer_.get(), updater_.get()); |
54 } | 54 } |
55 | 55 |
56 // Observes state changes on command ids 1 and 2. Ensure we don't get | 56 // Observes state changes on command ids 1 and 2. Ensure we don't get |
57 // a notification of a state change on a command we're not observing (3). | 57 // a notification of a state change on a command we're not observing (3). |
58 // Commands start off enabled in CommandUpdater. | 58 // Commands start off enabled in CommandUpdater. |
(...skipping 22 matching lines...) Expand all Loading... |
81 | 81 |
82 // Change something we're not watching and make sure the last state hasn't | 82 // Change something we're not watching and make sure the last state hasn't |
83 // changed. | 83 // changed. |
84 updater_->UpdateCommandEnabled(3, false); | 84 updater_->UpdateCommandEnabled(3, false); |
85 EXPECT_EQ([observer_ lastCommand], 1); | 85 EXPECT_EQ([observer_ lastCommand], 1); |
86 EXPECT_NE([observer_ lastCommand], 3); | 86 EXPECT_NE([observer_ lastCommand], 3); |
87 EXPECT_EQ([observer_ lastState], true); | 87 EXPECT_EQ([observer_ lastState], true); |
88 } | 88 } |
89 | 89 |
90 } // namespace | 90 } // namespace |
OLD | NEW |