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

Side by Side Diff: components/web_modal/web_contents_modal_dialog_manager_unittest.cc

Issue 23981002: Provide configurable closing of web contents modal dialogs on interstitial webui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + add test comment Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « components/web_modal/web_contents_modal_dialog_manager.cc ('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 (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 <map> 5 #include <map>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "components/web_modal/native_web_contents_modal_dialog_manager.h" 8 #include "components/web_modal/native_web_contents_modal_dialog_manager.h"
9 #include "components/web_modal/web_contents_modal_dialog_manager.h" 9 #include "components/web_modal/web_contents_modal_dialog_manager.h"
10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 manager->Observe(content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, 238 manager->Observe(content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
239 content::NotificationService::AllSources(), 239 content::NotificationService::AllSources(),
240 content::Details<bool>(&web_contents_visible)); 240 content::Details<bool>(&web_contents_visible));
241 241
242 EXPECT_TRUE(manager->IsShowingDialog()); 242 EXPECT_TRUE(manager->IsShowingDialog());
243 EXPECT_TRUE(delegate->web_contents_blocked()); 243 EXPECT_TRUE(delegate->web_contents_blocked());
244 EXPECT_EQ(TestNativeWebContentsModalDialogManager::SHOWN, 244 EXPECT_EQ(TestNativeWebContentsModalDialogManager::SHOWN,
245 native_manager->GetDialogState(dialog1)); 245 native_manager->GetDialogState(dialog1));
246 } 246 }
247 247
248 // Test that attaching an interstitial WebUI page closes dialogs configured to
249 // close on interstitial WebUI.
250 TEST_F(WebContentsModalDialogManagerTest, InterstitialWebUI) {
251 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog();
252 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog();
253 const NativeWebContentsModalDialog dialog3 = MakeFakeDialog();
254
255 manager->ShowDialog(dialog1);
256 manager->ShowDialog(dialog2);
257 manager->ShowDialog(dialog3);
258
259 manager->SetCloseOnInterstitialWebUI(dialog1, true);
260 manager->SetCloseOnInterstitialWebUI(dialog3, true);
261
262 test_api->DidAttachInterstitialPage();
263 EXPECT_EQ(TestNativeWebContentsModalDialogManager::CLOSED,
264 native_manager->GetDialogState(dialog1));
265 EXPECT_EQ(TestNativeWebContentsModalDialogManager::SHOWN,
266 native_manager->GetDialogState(dialog2));
267 EXPECT_EQ(TestNativeWebContentsModalDialogManager::CLOSED,
268 native_manager->GetDialogState(dialog3));
269 }
270
271
248 // Test that the first dialog is always shown, regardless of the order in which 272 // Test that the first dialog is always shown, regardless of the order in which
249 // dialogs are closed. 273 // dialogs are closed.
250 TEST_F(WebContentsModalDialogManagerTest, CloseDialogs) { 274 TEST_F(WebContentsModalDialogManagerTest, CloseDialogs) {
251 // The front dialog is always shown regardless of dialog close order. 275 // The front dialog is always shown regardless of dialog close order.
252 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog(); 276 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog();
253 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog(); 277 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog();
254 const NativeWebContentsModalDialog dialog3 = MakeFakeDialog(); 278 const NativeWebContentsModalDialog dialog3 = MakeFakeDialog();
255 const NativeWebContentsModalDialog dialog4 = MakeFakeDialog(); 279 const NativeWebContentsModalDialog dialog4 = MakeFakeDialog();
256 280
257 manager->ShowDialog(dialog1); 281 manager->ShowDialog(dialog1);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 332
309 EXPECT_EQ(0, native_manager->GetCloseCount()); 333 EXPECT_EQ(0, native_manager->GetCloseCount());
310 334
311 test_api->CloseAllDialogs(); 335 test_api->CloseAllDialogs();
312 EXPECT_FALSE(delegate->web_contents_blocked()); 336 EXPECT_FALSE(delegate->web_contents_blocked());
313 EXPECT_FALSE(manager->IsShowingDialog()); 337 EXPECT_FALSE(manager->IsShowingDialog());
314 EXPECT_EQ(kWindowCount, native_manager->GetCloseCount()); 338 EXPECT_EQ(kWindowCount, native_manager->GetCloseCount());
315 } 339 }
316 340
317 } // namespace web_modal 341 } // namespace web_modal
OLDNEW
« no previous file with comments | « components/web_modal/web_contents_modal_dialog_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698