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

Side by Side Diff: ios/chrome/browser/ui/dialogs/dialog_presenter_unittest.mm

Issue 2936643003: Allow cancelling the currently-presented dialog. (Closed)
Patch Set: fix compilation Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/dialogs/dialog_presenter.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/ui/dialogs/dialog_presenter.h" 5 #import "ios/chrome/browser/ui/dialogs/dialog_presenter.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" 8 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
9 #import "ios/web/public/test/fakes/test_web_state.h" 9 #import "ios/web/public/test/fakes/test_web_state.h"
10 #include "ios/web/public/web_state/web_state_observer.h" 10 #include "ios/web/public/web_state/web_state_observer.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 [presenter() runJavaScriptAlertPanelWithMessage:@"" 113 [presenter() runJavaScriptAlertPanelWithMessage:@""
114 requestURL:GURL() 114 requestURL:GURL()
115 webState:&webState2 115 webState:&webState2
116 completionHandler:nil]; 116 completionHandler:nil];
117 EXPECT_EQ(1U, delegate().presentedWebStates.size()); 117 EXPECT_EQ(1U, delegate().presentedWebStates.size());
118 EXPECT_EQ(&webState1, delegate().presentedWebStates.front()); 118 EXPECT_EQ(&webState1, delegate().presentedWebStates.front());
119 // Dismiss the dialog for |webState1| and call the confirm handler to trigger 119 // Dismiss the dialog for |webState1| and call the confirm handler to trigger
120 // showing the dialog for |webState2|. 120 // showing the dialog for |webState2|.
121 [presenter().presentedDialogCoordinator stop]; 121 [presenter().presentedDialogCoordinator stop];
122 [presenter() 122 [presenter()
123 buttonWasTappedForCoordinator:presenter().presentedDialogCoordinator]; 123 dialogCoordinatorWasStopped:presenter().presentedDialogCoordinator];
124 EXPECT_EQ(2U, delegate().presentedWebStates.size()); 124 EXPECT_EQ(2U, delegate().presentedWebStates.size());
125 EXPECT_EQ(&webState1, delegate().presentedWebStates.front()); 125 EXPECT_EQ(&webState1, delegate().presentedWebStates.front());
126 EXPECT_EQ(&webState2, delegate().presentedWebStates.back()); 126 EXPECT_EQ(&webState2, delegate().presentedWebStates.back());
127 } 127 }
128 128
129 // Tests that cancelling a queued JavaScript dialog will call its completion 129 // Tests that cancelling a queued JavaScript dialog will call its completion
130 // handler. 130 // handler.
131 TEST_F(DialogPresenterTest, CancelTest) { 131 TEST_F(DialogPresenterTest, CancelTest) {
132 // Show a dialog for |webState1| and enqueue a dialog for |webState2|. 132 // Show a dialog for |webState1| and enqueue a dialog for |webState2|.
133 DialogPresenterTestWebState webState1; 133 DialogPresenterTestWebState webState1;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 completion3_called = YES; 205 completion3_called = YES;
206 }]; 206 }];
207 EXPECT_EQ(1U, delegate().presentedWebStates.size()); 207 EXPECT_EQ(1U, delegate().presentedWebStates.size());
208 EXPECT_EQ(&webState1, delegate().presentedWebStates.front()); 208 EXPECT_EQ(&webState1, delegate().presentedWebStates.front());
209 // Cancel all dialogs and verify that all |completion_called| were called. 209 // Cancel all dialogs and verify that all |completion_called| were called.
210 [presenter() cancelAllDialogs]; 210 [presenter() cancelAllDialogs];
211 EXPECT_TRUE(completion1_called); 211 EXPECT_TRUE(completion1_called);
212 EXPECT_TRUE(completion2_called); 212 EXPECT_TRUE(completion2_called);
213 EXPECT_TRUE(completion3_called); 213 EXPECT_TRUE(completion3_called);
214 } 214 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/dialogs/dialog_presenter.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698