summaryrefslogtreecommitdiffstats
path: root/chrome/browser/command_updater_unittest.cc
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-09 19:40:36 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-09 19:40:36 +0000
commitf7d2e27ced01c18236df1bbdd6d62937c596cd5d (patch)
treefae3ab38ff339525ffca1edea9f03521bd1a9ccd /chrome/browser/command_updater_unittest.cc
parentcd4fd156aba80ddffd3fffd8e2d8703247181fe0 (diff)
downloadchromium_src-f7d2e27ced01c18236df1bbdd6d62937c596cd5d.zip
chromium_src-f7d2e27ced01c18236df1bbdd6d62937c596cd5d.tar.gz
chromium_src-f7d2e27ced01c18236df1bbdd6d62937c596cd5d.tar.bz2
Test the RemoveCommandObserver() routine that removes an observer from all its registered commands.
Review URL: http://codereview.chromium.org/20180 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/command_updater_unittest.cc')
-rw-r--r--chrome/browser/command_updater_unittest.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/browser/command_updater_unittest.cc b/chrome/browser/command_updater_unittest.cc
index 0297cbc..d090d3d 100644
--- a/chrome/browser/command_updater_unittest.cc
+++ b/chrome/browser/command_updater_unittest.cc
@@ -75,3 +75,34 @@ TEST_F(CommandUpdaterTest, TestObservers) {
command_updater.UpdateCommandEnabled(2, true);
EXPECT_FALSE(observer.enabled());
}
+
+TEST_F(CommandUpdaterTest, TestObserverRemovingAllCommands) {
+ TestingCommandHandlerMock handler;
+ CommandUpdater command_updater(&handler);
+
+ // Create two observers for the commands 1-3 as true, remove one using the
+ // single remove command, then set the command to false. Ensure that the
+ // removed observer still thinks all commands are true and the one left
+ // observing picked up the change.
+
+ TestingCommandObserverMock observer_remove, observer_keep;
+ command_updater.AddCommandObserver(1, &observer_remove);
+ command_updater.AddCommandObserver(2, &observer_remove);
+ command_updater.AddCommandObserver(3, &observer_remove);
+ command_updater.AddCommandObserver(1, &observer_keep);
+ command_updater.AddCommandObserver(2, &observer_keep);
+ command_updater.AddCommandObserver(3, &observer_keep);
+ command_updater.UpdateCommandEnabled(1, true);
+ command_updater.UpdateCommandEnabled(2, true);
+ command_updater.UpdateCommandEnabled(3, true);
+ EXPECT_TRUE(observer_remove.enabled());
+
+ // Remove one observer and update the command. Check the states, which
+ // should be different.
+ command_updater.RemoveCommandObserver(&observer_remove);
+ command_updater.UpdateCommandEnabled(1, false);
+ command_updater.UpdateCommandEnabled(2, false);
+ command_updater.UpdateCommandEnabled(3, false);
+ EXPECT_TRUE(observer_remove.enabled());
+ EXPECT_FALSE(observer_keep.enabled());
+}