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 void ExecuteCommandWithDisposition(int id, WindowOpenDisposition) override { |
15 WindowOpenDisposition) override { | |
16 EXPECT_EQ(1, id); | 15 EXPECT_EQ(1, id); |
17 } | 16 } |
18 }; | 17 }; |
19 | 18 |
20 class FakeCommandObserver : public CommandObserver { | 19 class FakeCommandObserver : public CommandObserver { |
21 public: | 20 public: |
22 FakeCommandObserver() : enabled_(true) {} | 21 FakeCommandObserver() : enabled_(true) {} |
23 | 22 |
24 virtual void EnabledStateChangedForCommand(int id, bool enabled) override { | 23 void EnabledStateChangedForCommand(int id, bool enabled) override { |
25 enabled_ = enabled; | 24 enabled_ = enabled; |
26 } | 25 } |
27 | 26 |
28 bool enabled() const { return enabled_; } | 27 bool enabled() const { return enabled_; } |
29 | 28 |
30 private: | 29 private: |
31 bool enabled_; | 30 bool enabled_; |
32 }; | 31 }; |
33 | 32 |
34 TEST(CommandUpdaterTest, TestBasicAPI) { | 33 TEST(CommandUpdaterTest, TestBasicAPI) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 98 |
100 // Remove one observer and update the command. Check the states, which | 99 // Remove one observer and update the command. Check the states, which |
101 // should be different. | 100 // should be different. |
102 command_updater.RemoveCommandObserver(&observer_remove); | 101 command_updater.RemoveCommandObserver(&observer_remove); |
103 command_updater.UpdateCommandEnabled(1, false); | 102 command_updater.UpdateCommandEnabled(1, false); |
104 command_updater.UpdateCommandEnabled(2, false); | 103 command_updater.UpdateCommandEnabled(2, false); |
105 command_updater.UpdateCommandEnabled(3, false); | 104 command_updater.UpdateCommandEnabled(3, false); |
106 EXPECT_TRUE(observer_remove.enabled()); | 105 EXPECT_TRUE(observer_remove.enabled()); |
107 EXPECT_FALSE(observer_keep.enabled()); | 106 EXPECT_FALSE(observer_keep.enabled()); |
108 } | 107 } |
OLD | NEW |