OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/javascript_dialog_blocking_util.h" | 5 #import "ios/chrome/browser/ui/dialogs/javascript_dialog_blocking_util.h" |
6 | 6 |
7 #include "ios/web/public/load_committed_details.h" | 7 #include "ios/web/public/load_committed_details.h" |
8 #include "ios/web/public/test/test_web_state.h" | 8 #import "ios/web/public/test/fakes/test_web_state.h" |
9 #include "ios/web/public/web_state/web_state_observer.h" | 9 #include "ios/web/public/web_state/web_state_observer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 #if !defined(__has_feature) || !__has_feature(objc_arc) | 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
13 #error "This file requires ARC support." | 13 #error "This file requires ARC support." |
14 #endif | 14 #endif |
15 | 15 |
16 namespace { | 16 namespace { |
17 // TestWebState subclass that allows simulating page loads. | 17 // TestWebState subclass that allows simulating page loads. |
18 class JavaScriptBlockingTestWebState : public web::TestWebState { | 18 class JavaScriptBlockingTestWebState : public web::TestWebState { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 // Tests that ShouldBlockDialogsForPresenter() returns false after a page load. | 65 // Tests that ShouldBlockDialogsForPresenter() returns false after a page load. |
66 TEST(JavaScriptDialogBlockingTest, StopBlocking) { | 66 TEST(JavaScriptDialogBlockingTest, StopBlocking) { |
67 JavaScriptBlockingTestWebState webState; | 67 JavaScriptBlockingTestWebState webState; |
68 EXPECT_FALSE(ShouldBlockJavaScriptDialogs(&webState)); | 68 EXPECT_FALSE(ShouldBlockJavaScriptDialogs(&webState)); |
69 DialogBlockingOptionSelected(&webState); | 69 DialogBlockingOptionSelected(&webState); |
70 EXPECT_TRUE(ShouldBlockJavaScriptDialogs(&webState)); | 70 EXPECT_TRUE(ShouldBlockJavaScriptDialogs(&webState)); |
71 webState.SimulatePageLoaded(); | 71 webState.SimulatePageLoaded(); |
72 EXPECT_FALSE(ShouldBlockJavaScriptDialogs(&webState)); | 72 EXPECT_FALSE(ShouldBlockJavaScriptDialogs(&webState)); |
73 } | 73 } |
OLD | NEW |