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

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

Issue 2481503002: Fix JavaScriptBlockingTestWebState constructor to initialize |observer_| (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | 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 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 #include "ios/web/public/test/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 {
19 public: 19 public:
20 JavaScriptBlockingTestWebState() : web::TestWebState(), observer_(nullptr) {}
20 ~JavaScriptBlockingTestWebState() override { 21 ~JavaScriptBlockingTestWebState() override {
21 if (observer_) 22 if (observer_)
22 observer_->WebStateDestroyed(); 23 observer_->WebStateDestroyed();
23 } 24 }
24 25
25 // Simulates a page load by sending a WebStateObserver callback. 26 // Simulates a page load by sending a WebStateObserver callback.
26 void SimulatePageLoaded() { 27 void SimulatePageLoaded() {
27 web::LoadCommittedDetails details; 28 web::LoadCommittedDetails details;
28 if (observer_) 29 if (observer_)
29 observer_->NavigationItemCommitted(details); 30 observer_->NavigationItemCommitted(details);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 // Tests that ShouldBlockDialogsForPresenter() returns false after a page load. 65 // Tests that ShouldBlockDialogsForPresenter() returns false after a page load.
65 TEST(JavaScriptDialogBlockingTest, StopBlocking) { 66 TEST(JavaScriptDialogBlockingTest, StopBlocking) {
66 JavaScriptBlockingTestWebState webState; 67 JavaScriptBlockingTestWebState webState;
67 EXPECT_FALSE(ShouldBlockJavaScriptDialogs(&webState)); 68 EXPECT_FALSE(ShouldBlockJavaScriptDialogs(&webState));
68 DialogBlockingOptionSelected(&webState); 69 DialogBlockingOptionSelected(&webState);
69 EXPECT_TRUE(ShouldBlockJavaScriptDialogs(&webState)); 70 EXPECT_TRUE(ShouldBlockJavaScriptDialogs(&webState));
70 webState.SimulatePageLoaded(); 71 webState.SimulatePageLoaded();
71 EXPECT_FALSE(ShouldBlockJavaScriptDialogs(&webState)); 72 EXPECT_FALSE(ShouldBlockJavaScriptDialogs(&webState));
72 } 73 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698