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

Side by Side Diff: ios/web/web_state/ui/crw_web_controller_unittest.mm

Issue 2567303003: [ios] Removed unused CRWWebControllerObserver methods. (Closed)
Patch Set: Self review Created 4 years 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #import "ios/web/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/ios/ios_util.h" 11 #include "base/ios/ios_util.h"
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #include "base/strings/sys_string_conversions.h"
14 #import "base/test/ios/wait_util.h" 13 #import "base/test/ios/wait_util.h"
15 #include "base/values.h"
16 #import "ios/testing/ocmock_complex_type_helper.h" 14 #import "ios/testing/ocmock_complex_type_helper.h"
17 #include "ios/web/navigation/crw_session_controller.h" 15 #include "ios/web/navigation/crw_session_controller.h"
18 #include "ios/web/navigation/crw_session_entry.h" 16 #include "ios/web/navigation/crw_session_entry.h"
19 #include "ios/web/navigation/navigation_item_impl.h" 17 #include "ios/web/navigation/navigation_item_impl.h"
20 #import "ios/web/navigation/navigation_manager_impl.h" 18 #import "ios/web/navigation/navigation_manager_impl.h"
21 #include "ios/web/public/referrer.h" 19 #include "ios/web/public/referrer.h"
22 #import "ios/web/public/test/test_native_content.h" 20 #import "ios/web/public/test/test_native_content.h"
23 #import "ios/web/public/test/test_native_content_provider.h" 21 #import "ios/web/public/test/test_native_content_provider.h"
24 #import "ios/web/public/test/test_web_client.h" 22 #import "ios/web/public/test/test_web_client.h"
25 #include "ios/web/public/test/test_web_view_content_view.h" 23 #include "ios/web/public/test/test_web_view_content_view.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 shouldOpenURL:(const GURL&)URL 195 shouldOpenURL:(const GURL&)URL
198 mainDocumentURL:(const GURL&)mainDocumentURL 196 mainDocumentURL:(const GURL&)mainDocumentURL
199 linkClicked:(BOOL)linkClicked { 197 linkClicked:(BOOL)linkClicked {
200 return YES; 198 return YES;
201 } 199 }
202 @end 200 @end
203 201
204 @interface CountingObserver : NSObject<CRWWebControllerObserver> 202 @interface CountingObserver : NSObject<CRWWebControllerObserver>
205 203
206 @property(nonatomic, readonly) int pageLoadedCount; 204 @property(nonatomic, readonly) int pageLoadedCount;
207 @property(nonatomic, readonly) int messageCount;
208 @end 205 @end
209 206
210 @implementation CountingObserver 207 @implementation CountingObserver
211 @synthesize pageLoadedCount = _pageLoadedCount; 208 @synthesize pageLoadedCount = _pageLoadedCount;
212 @synthesize messageCount = _messageCount;
213 209
214 - (void)pageLoaded:(CRWWebController*)webController { 210 - (void)pageLoaded:(CRWWebController*)webController {
215 ++_pageLoadedCount; 211 ++_pageLoadedCount;
216 } 212 }
217 213
218 - (BOOL)handleCommand:(const base::DictionaryValue&)command
219 webController:(CRWWebController*)webController
220 userIsInteracting:(BOOL)userIsInteracting
221 originURL:(const GURL&)originURL {
222 ++_messageCount;
223 return YES;
224 }
225
226 - (NSString*)commandPrefix {
227 return @"wctest";
228 }
229
230 @end 214 @end
231 215
232 namespace { 216 namespace {
233 217
234 const char kTestURLString[] = "http://www.google.com/"; 218 const char kTestURLString[] = "http://www.google.com/";
235 const char kTestAppSpecificURL[] = "testwebui://test/"; 219 const char kTestAppSpecificURL[] = "testwebui://test/";
236 220
237 // Returns true if the current device is a large iPhone (6 or 6+). 221 // Returns true if the current device is a large iPhone (6 or 6+).
238 bool IsIPhone6Or6Plus() { 222 bool IsIPhone6Or6Plus() {
239 UIUserInterfaceIdiom idiom = [[UIDevice currentDevice] userInterfaceIdiom]; 223 UIUserInterfaceIdiom idiom = [[UIDevice currentDevice] userInterfaceIdiom];
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 EXPECT_EQ(0u, [web_controller() observerCount]); 884 EXPECT_EQ(0u, [web_controller() observerCount]);
901 [web_controller() addObserver:observer]; 885 [web_controller() addObserver:observer];
902 EXPECT_EQ(1u, [web_controller() observerCount]); 886 EXPECT_EQ(1u, [web_controller() observerCount]);
903 887
904 EXPECT_EQ(0, [observer pageLoadedCount]); 888 EXPECT_EQ(0, [observer pageLoadedCount]);
905 [web_controller() webStateImpl]->OnPageLoaded(GURL("http://test"), false); 889 [web_controller() webStateImpl]->OnPageLoaded(GURL("http://test"), false);
906 EXPECT_EQ(0, [observer pageLoadedCount]); 890 EXPECT_EQ(0, [observer pageLoadedCount]);
907 [web_controller() webStateImpl]->OnPageLoaded(GURL("http://test"), true); 891 [web_controller() webStateImpl]->OnPageLoaded(GURL("http://test"), true);
908 EXPECT_EQ(1, [observer pageLoadedCount]); 892 EXPECT_EQ(1, [observer pageLoadedCount]);
909 893
910 EXPECT_EQ(0, [observer messageCount]);
911 // Non-matching prefix.
912 EXPECT_FALSE([web_controller() webStateImpl]->OnScriptCommandReceived(
913 "a", base::DictionaryValue(), GURL("http://test"), true));
914 EXPECT_EQ(0, [observer messageCount]);
915 // Matching prefix.
916 EXPECT_TRUE([web_controller() webStateImpl]->OnScriptCommandReceived(
917 base::SysNSStringToUTF8([observer commandPrefix]) + ".foo",
918 base::DictionaryValue(), GURL("http://test"), true));
919 EXPECT_EQ(1, [observer messageCount]);
920
921 [web_controller() removeObserver:observer]; 894 [web_controller() removeObserver:observer];
922 EXPECT_EQ(0u, [web_controller() observerCount]); 895 EXPECT_EQ(0u, [web_controller() observerCount]);
923 }; 896 };
924 897
925 // Test fixture for window.open tests. 898 // Test fixture for window.open tests.
926 class CRWWebControllerWindowOpenTest : public web::WebTestWithWebController { 899 class CRWWebControllerWindowOpenTest : public web::WebTestWithWebController {
927 protected: 900 protected:
928 void SetUp() override { 901 void SetUp() override {
929 web::WebTestWithWebController::SetUp(); 902 web::WebTestWithWebController::SetUp();
930 903
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 1046
1074 [web_controller() setDelegate:delegate]; 1047 [web_controller() setDelegate:delegate];
1075 web::SimulateWKWebViewCrash(webView_); 1048 web::SimulateWKWebViewCrash(webView_);
1076 1049
1077 EXPECT_OCMOCK_VERIFY(delegate); 1050 EXPECT_OCMOCK_VERIFY(delegate);
1078 EXPECT_FALSE([web_controller() isViewAlive]); 1051 EXPECT_FALSE([web_controller() isViewAlive]);
1079 [web_controller() setDelegate:nil]; 1052 [web_controller() setDelegate:nil];
1080 }; 1053 };
1081 1054
1082 } // namespace 1055 } // namespace
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller_observer_unittest.mm ('k') | ios/web/web_state/web_controller_observer_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698