| 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 "components/web_modal/web_contents_modal_dialog_manager.h" | 5 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "components/web_modal/single_web_contents_dialog_manager.h" | 10 #include "components/web_modal/single_web_contents_dialog_manager.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 234 |
| 235 test_api->WebContentsWasShown(); | 235 test_api->WebContentsWasShown(); |
| 236 | 236 |
| 237 EXPECT_TRUE(manager->IsDialogActive()); | 237 EXPECT_TRUE(manager->IsDialogActive()); |
| 238 EXPECT_TRUE(delegate->web_contents_blocked()); | 238 EXPECT_TRUE(delegate->web_contents_blocked()); |
| 239 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker.state_); | 239 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker.state_); |
| 240 | 240 |
| 241 native_manager->StopTracking(); | 241 native_manager->StopTracking(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 // Test that attaching an interstitial page closes dialogs configured to close. | 244 // Test that attaching an interstitial page closes all dialogs. |
| 245 TEST_F(WebContentsModalDialogManagerTest, InterstitialPage) { | 245 TEST_F(WebContentsModalDialogManagerTest, InterstitialPage) { |
| 246 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog(); | 246 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog(); |
| 247 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog(); | 247 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog(); |
| 248 const NativeWebContentsModalDialog dialog3 = MakeFakeDialog(); | |
| 249 | 248 |
| 250 NativeManagerTracker tracker1; | 249 NativeManagerTracker tracker1; |
| 251 NativeManagerTracker tracker2; | 250 NativeManagerTracker tracker2; |
| 252 NativeManagerTracker tracker3; | |
| 253 TestNativeWebContentsModalDialogManager* native_manager1 = | 251 TestNativeWebContentsModalDialogManager* native_manager1 = |
| 254 new TestNativeWebContentsModalDialogManager(dialog1, manager, &tracker1); | 252 new TestNativeWebContentsModalDialogManager(dialog1, manager, &tracker1); |
| 255 TestNativeWebContentsModalDialogManager* native_manager2 = | 253 TestNativeWebContentsModalDialogManager* native_manager2 = |
| 256 new TestNativeWebContentsModalDialogManager(dialog2, manager, &tracker2); | 254 new TestNativeWebContentsModalDialogManager(dialog2, manager, &tracker2); |
| 257 TestNativeWebContentsModalDialogManager* native_manager3 = | |
| 258 new TestNativeWebContentsModalDialogManager(dialog3, manager, &tracker3); | |
| 259 manager->ShowDialogWithManager(dialog1, | 255 manager->ShowDialogWithManager(dialog1, |
| 260 scoped_ptr<SingleWebContentsDialogManager>(native_manager1).Pass()); | 256 scoped_ptr<SingleWebContentsDialogManager>(native_manager1).Pass()); |
| 261 manager->ShowDialogWithManager(dialog2, | 257 manager->ShowDialogWithManager(dialog2, |
| 262 scoped_ptr<SingleWebContentsDialogManager>(native_manager2).Pass()); | 258 scoped_ptr<SingleWebContentsDialogManager>(native_manager2).Pass()); |
| 263 manager->ShowDialogWithManager(dialog3, | |
| 264 scoped_ptr<SingleWebContentsDialogManager>(native_manager3).Pass()); | |
| 265 | |
| 266 #if defined(OS_WIN) || defined(USE_AURA) | |
| 267 manager->SetCloseOnInterstitialPage(dialog2, false); | |
| 268 #else | |
| 269 // TODO(wittman): Remove this section once Mac is changed to close on | |
| 270 // interstitial pages by default. | |
| 271 manager->SetCloseOnInterstitialPage(dialog1, true); | |
| 272 manager->SetCloseOnInterstitialPage(dialog3, true); | |
| 273 #endif | |
| 274 | 259 |
| 275 test_api->DidAttachInterstitialPage(); | 260 test_api->DidAttachInterstitialPage(); |
| 276 | 261 |
| 262 #if defined(USE_AURA) |
| 277 EXPECT_EQ(NativeManagerTracker::CLOSED, tracker1.state_); | 263 EXPECT_EQ(NativeManagerTracker::CLOSED, tracker1.state_); |
| 278 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker2.state_); | 264 EXPECT_EQ(NativeManagerTracker::CLOSED, tracker2.state_); |
| 279 EXPECT_EQ(NativeManagerTracker::CLOSED, tracker3.state_); | 265 #else |
| 266 EXPECT_EQ(NativeManagerTracker::SHOWN, tracker1.state_); |
| 267 EXPECT_EQ(NativeManagerTracker::NOT_SHOWN, tracker2.state_); |
| 268 #endif |
| 269 |
| 280 EXPECT_TRUE(tracker1.was_shown_); | 270 EXPECT_TRUE(tracker1.was_shown_); |
| 281 EXPECT_TRUE(tracker2.was_shown_); | 271 EXPECT_FALSE(tracker2.was_shown_); |
| 282 EXPECT_FALSE(tracker3.was_shown_); | |
| 283 | 272 |
| 273 #if !defined(USE_AURA) |
| 274 native_manager1->StopTracking(); |
| 284 native_manager2->StopTracking(); | 275 native_manager2->StopTracking(); |
| 276 #endif |
| 285 } | 277 } |
| 286 | 278 |
| 287 | 279 |
| 288 // Test that the first dialog is always shown, regardless of the order in which | 280 // Test that the first dialog is always shown, regardless of the order in which |
| 289 // dialogs are closed. | 281 // dialogs are closed. |
| 290 TEST_F(WebContentsModalDialogManagerTest, CloseDialogs) { | 282 TEST_F(WebContentsModalDialogManagerTest, CloseDialogs) { |
| 291 // The front dialog is always shown regardless of dialog close order. | 283 // The front dialog is always shown regardless of dialog close order. |
| 292 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog(); | 284 const NativeWebContentsModalDialog dialog1 = MakeFakeDialog(); |
| 293 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog(); | 285 const NativeWebContentsModalDialog dialog2 = MakeFakeDialog(); |
| 294 const NativeWebContentsModalDialog dialog3 = MakeFakeDialog(); | 286 const NativeWebContentsModalDialog dialog3 = MakeFakeDialog(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 370 |
| 379 test_api->CloseAllDialogs(); | 371 test_api->CloseAllDialogs(); |
| 380 | 372 |
| 381 EXPECT_FALSE(delegate->web_contents_blocked()); | 373 EXPECT_FALSE(delegate->web_contents_blocked()); |
| 382 EXPECT_FALSE(manager->IsDialogActive()); | 374 EXPECT_FALSE(manager->IsDialogActive()); |
| 383 for (int i = 0; i < kWindowCount; i++) | 375 for (int i = 0; i < kWindowCount; i++) |
| 384 EXPECT_EQ(NativeManagerTracker::CLOSED, trackers[i].state_); | 376 EXPECT_EQ(NativeManagerTracker::CLOSED, trackers[i].state_); |
| 385 } | 377 } |
| 386 | 378 |
| 387 } // namespace web_modal | 379 } // namespace web_modal |
| OLD | NEW |