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

Unified Diff: ios/shared/chrome/browser/ui/commands/command_dispatcher_unittest.mm

Issue 2779213003: [clean] Use CommandDispatcher to show/close Settings. (Closed)
Patch Set: Fix tests Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/shared/chrome/browser/ui/commands/command_dispatcher.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/shared/chrome/browser/ui/commands/command_dispatcher_unittest.mm
diff --git a/ios/shared/chrome/browser/ui/commands/command_dispatcher_unittest.mm b/ios/shared/chrome/browser/ui/commands/command_dispatcher_unittest.mm
index b4958bccf39cc906bb0aad660ba5510c439ec46d..c9ffdd6517879756cc4e5b6a80e93ab7bf3d6927 100644
--- a/ios/shared/chrome/browser/ui/commands/command_dispatcher_unittest.mm
+++ b/ios/shared/chrome/browser/ui/commands/command_dispatcher_unittest.mm
@@ -160,7 +160,6 @@ TEST(CommandDispatcherTest, TargetWithArguments) {
EXPECT_EQ(13, [dispatcher methodToAddFirstArgument:7 toSecond:6]);
EXPECT_FALSE(target.intMethodCalled);
EXPECT_FALSE(target.objectMethodCalled);
- EXPECT_EQ(42, [dispatcher methodToAddFirstArgument:34 toSecond:8]);
}
// Tests that messages are routed to the proper handler when multiple targets
@@ -185,8 +184,39 @@ TEST(CommandDispatcherTest, MultipleTargets) {
EXPECT_TRUE(hideTarget.hideCalled);
}
-// Tests that handlers are no longer forwarded messages after deregistration.
-TEST(CommandDispatcherTest, Deregistration) {
+// Tests that handlers are no longer forwarded messages after selector
+// deregistration.
+TEST(CommandDispatcherTest, SelectorDeregistration) {
+ id dispatcher = [[CommandDispatcher alloc] init];
+ CommandDispatcherTestSimpleTarget* target =
+ [[CommandDispatcherTestSimpleTarget alloc] init];
+
+ [dispatcher startDispatchingToTarget:target forSelector:@selector(show)];
+ [dispatcher startDispatchingToTarget:target forSelector:@selector(hide)];
+
+ [dispatcher show];
+ EXPECT_TRUE(target.showCalled);
+ EXPECT_FALSE(target.hideCalled);
+
+ [target resetProperties];
+ [dispatcher stopDispatchingForSelector:@selector(show)];
+ bool exception_caught = false;
+ @try {
+ [dispatcher show];
+ } @catch (NSException* exception) {
+ EXPECT_EQ(NSInvalidArgumentException, [exception name]);
+ exception_caught = true;
+ }
+ EXPECT_TRUE(exception_caught);
+
+ [dispatcher hide];
+ EXPECT_FALSE(target.showCalled);
+ EXPECT_TRUE(target.hideCalled);
+}
+
+// Tests that handlers are no longer forwarded messages after target
+// deregistration.
+TEST(CommandDispatcherTest, TargetDeregistration) {
id dispatcher = [[CommandDispatcher alloc] init];
CommandDispatcherTestSimpleTarget* showTarget =
[[CommandDispatcherTestSimpleTarget alloc] init];
« no previous file with comments | « ios/shared/chrome/browser/ui/commands/command_dispatcher.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698