OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/command_updater.h" | 5 #include "chrome/browser/command_updater.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "chrome/browser/command_observer.h" | 8 #include "chrome/browser/command_observer.h" |
9 #include "chrome/browser/command_updater_delegate.h" | 9 #include "chrome/browser/command_updater_delegate.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 class FakeCommandUpdaterDelegate : public CommandUpdaterDelegate { | 12 class FakeCommandUpdaterDelegate : public CommandUpdaterDelegate { |
13 public: | 13 public: |
14 virtual void ExecuteCommandWithDisposition(int id, | 14 virtual void ExecuteCommandWithDisposition(int id, |
15 WindowOpenDisposition) OVERRIDE { | 15 WindowOpenDisposition) override { |
16 EXPECT_EQ(1, id); | 16 EXPECT_EQ(1, id); |
17 } | 17 } |
18 }; | 18 }; |
19 | 19 |
20 class FakeCommandObserver : public CommandObserver { | 20 class FakeCommandObserver : public CommandObserver { |
21 public: | 21 public: |
22 FakeCommandObserver() : enabled_(true) {} | 22 FakeCommandObserver() : enabled_(true) {} |
23 | 23 |
24 virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE { | 24 virtual void EnabledStateChangedForCommand(int id, bool enabled) override { |
25 enabled_ = enabled; | 25 enabled_ = enabled; |
26 } | 26 } |
27 | 27 |
28 bool enabled() const { return enabled_; } | 28 bool enabled() const { return enabled_; } |
29 | 29 |
30 private: | 30 private: |
31 bool enabled_; | 31 bool enabled_; |
32 }; | 32 }; |
33 | 33 |
34 TEST(CommandUpdaterTest, TestBasicAPI) { | 34 TEST(CommandUpdaterTest, TestBasicAPI) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 // Remove one observer and update the command. Check the states, which | 100 // Remove one observer and update the command. Check the states, which |
101 // should be different. | 101 // should be different. |
102 command_updater.RemoveCommandObserver(&observer_remove); | 102 command_updater.RemoveCommandObserver(&observer_remove); |
103 command_updater.UpdateCommandEnabled(1, false); | 103 command_updater.UpdateCommandEnabled(1, false); |
104 command_updater.UpdateCommandEnabled(2, false); | 104 command_updater.UpdateCommandEnabled(2, false); |
105 command_updater.UpdateCommandEnabled(3, false); | 105 command_updater.UpdateCommandEnabled(3, false); |
106 EXPECT_TRUE(observer_remove.enabled()); | 106 EXPECT_TRUE(observer_remove.enabled()); |
107 EXPECT_FALSE(observer_keep.enabled()); | 107 EXPECT_FALSE(observer_keep.enabled()); |
108 } | 108 } |
OLD | NEW |