summaryrefslogtreecommitdiffstats
path: root/ios
diff options
context:
space:
mode:
authorshreyasv <shreyasv@chromium.org>2016-03-16 13:58:56 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-16 21:00:50 +0000
commit4caf5d6fb5d3ab9e8d53db06350cc7a45a6f3fa0 (patch)
treef4489d52e39b7b6426ca17ffe2f655229689ee70 /ios
parent376c69d2c253569a9404c750cdd2b0a93eebedac (diff)
downloadchromium_src-4caf5d6fb5d3ab9e8d53db06350cc7a45a6f3fa0.zip
chromium_src-4caf5d6fb5d3ab9e8d53db06350cc7a45a6f3fa0.tar.gz
chromium_src-4caf5d6fb5d3ab9e8d53db06350cc7a45a6f3fa0.tar.bz2
Removing CRWUISimpleWebViewController
No longer needed. BUG=579697 Review URL: https://codereview.chromium.org/1804273002 Cr-Commit-Position: refs/heads/master@{#381539}
Diffstat (limited to 'ios')
-rw-r--r--ios/web/BUILD.gn3
-rw-r--r--ios/web/ios_web.gyp2
-rw-r--r--ios/web/ios_web_unittests.gyp1
-rw-r--r--ios/web/web_state/ui/crw_ui_simple_web_view_controller.h21
-rw-r--r--ios/web/web_state/ui/crw_ui_simple_web_view_controller.mm106
-rw-r--r--ios/web/web_state/ui/crw_ui_simple_web_view_controller_unittest.mm111
6 files changed, 0 insertions, 244 deletions
diff --git a/ios/web/BUILD.gn b/ios/web/BUILD.gn
index ace65c8..d1858ca 100644
--- a/ios/web/BUILD.gn
+++ b/ios/web/BUILD.gn
@@ -224,8 +224,6 @@ source_set("web") {
"web_state/ui/crw_swipe_recognizer_provider.h",
"web_state/ui/crw_touch_tracking_recognizer.h",
"web_state/ui/crw_touch_tracking_recognizer.mm",
- "web_state/ui/crw_ui_simple_web_view_controller.h",
- "web_state/ui/crw_ui_simple_web_view_controller.mm",
"web_state/ui/crw_web_controller+protected.h",
"web_state/ui/crw_web_controller.h",
"web_state/ui/crw_web_controller.mm",
@@ -425,7 +423,6 @@ test("ios_web_unittests") {
"web_state/js/crw_js_window_id_manager_unittest.mm",
"web_state/js/page_script_util_unittest.mm",
"web_state/ui/crw_static_file_web_view_unittest.mm",
- "web_state/ui/crw_ui_simple_web_view_controller_unittest.mm",
"web_state/ui/crw_web_controller_container_view_unittest.mm",
"web_state/ui/crw_web_controller_observer_unittest.mm",
"web_state/ui/crw_web_controller_unittest.mm",
diff --git a/ios/web/ios_web.gyp b/ios/web/ios_web.gyp
index 49aff7f..4797b93 100644
--- a/ios/web/ios_web.gyp
+++ b/ios/web/ios_web.gyp
@@ -260,8 +260,6 @@
'web_state/ui/crw_swipe_recognizer_provider.h',
'web_state/ui/crw_touch_tracking_recognizer.h',
'web_state/ui/crw_touch_tracking_recognizer.mm',
- 'web_state/ui/crw_ui_simple_web_view_controller.h',
- 'web_state/ui/crw_ui_simple_web_view_controller.mm',
'web_state/ui/crw_web_controller+protected.h',
'web_state/ui/crw_web_controller.h',
'web_state/ui/crw_web_controller.mm',
diff --git a/ios/web/ios_web_unittests.gyp b/ios/web/ios_web_unittests.gyp
index 4964ff5..ed4edae 100644
--- a/ios/web/ios_web_unittests.gyp
+++ b/ios/web/ios_web_unittests.gyp
@@ -67,7 +67,6 @@
'web_state/js/crw_js_window_id_manager_unittest.mm',
'web_state/js/page_script_util_unittest.mm',
'web_state/ui/crw_static_file_web_view_unittest.mm',
- 'web_state/ui/crw_ui_simple_web_view_controller_unittest.mm',
'web_state/ui/crw_web_controller_container_view_unittest.mm',
'web_state/ui/crw_web_controller_observer_unittest.mm',
'web_state/ui/crw_web_controller_unittest.mm',
diff --git a/ios/web/web_state/ui/crw_ui_simple_web_view_controller.h b/ios/web/web_state/ui/crw_ui_simple_web_view_controller.h
deleted file mode 100644
index 036eb52..0000000
--- a/ios/web/web_state/ui/crw_ui_simple_web_view_controller.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef IOS_WEB_WEB_STATE_UI_CRW_UI_SIMPLE_WEB_VIEW_CONTROLLER_H_
-#define IOS_WEB_WEB_STATE_UI_CRW_UI_SIMPLE_WEB_VIEW_CONTROLLER_H_
-
-#import <UIKit/UIKit.h>
-
-#import "ios/web/web_state/ui/crw_simple_web_view_controller.h"
-
-// A CRWSimpleWebViewController implentation backed by an UIWebView.
-@interface CRWUISimpleWebViewController : NSObject<CRWSimpleWebViewController>
-
-// Designated initializer. Initializes a new view controller backed by a
-// UIWebView.
-- (instancetype)initWithUIWebView:(UIWebView*)webView;
-
-@end
-
-#endif // IOS_WEB_WEB_STATE_UI_CRW_UI_SIMPLE_WEB_VIEW_CONTROLLER_H_
diff --git a/ios/web/web_state/ui/crw_ui_simple_web_view_controller.mm b/ios/web/web_state/ui/crw_ui_simple_web_view_controller.mm
deleted file mode 100644
index 7d12883..0000000
--- a/ios/web/web_state/ui/crw_ui_simple_web_view_controller.mm
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ios/web/web_state/ui/crw_ui_simple_web_view_controller.h"
-
-#include "base/ios/weak_nsobject.h"
-#import "base/logging.h"
-#import "base/mac/scoped_nsobject.h"
-
-@interface CRWUISimpleWebViewController () <UIWebViewDelegate>
-@end
-
-@implementation CRWUISimpleWebViewController {
- base::scoped_nsobject<UIWebView> _webView;
- base::WeakNSProtocol<id<CRWSimpleWebViewControllerDelegate>> _delegate;
-}
-
-- (instancetype)initWithUIWebView:(UIWebView*)webView {
- self = [super init];
- if (self) {
- DCHECK(webView);
- _webView.reset([webView retain]);
- [_webView setDelegate:self];
- }
- return self;
-}
-
-- (void)dealloc {
- [_webView setDelegate:nil];
- [super dealloc];
-}
-
-#pragma mark -
-#pragma mark CRWSimpleWebView implementation
-
-- (void)reload {
- [_webView reload];
-}
-
-- (UIView*)view {
- return _webView.get();
-}
-
-- (UIScrollView*)scrollView {
- return [_webView scrollView];
-}
-
-- (NSString*)title {
- return [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];
-}
-
-- (void)loadRequest:(NSURLRequest*)request {
- [_webView loadRequest:request];
-}
-
-- (void)loadHTMLString:(NSString*)html baseURL:(NSURL*)baseURL {
- [_webView loadHTMLString:html baseURL:baseURL];
-}
-
-- (void)setDelegate:(id<CRWSimpleWebViewControllerDelegate>)delegate {
- _delegate.reset(delegate);
-}
-
-- (id<CRWSimpleWebViewControllerDelegate>)delegate {
- return _delegate.get();
-}
-
-- (void)loadPDFAtFilePath:(NSString*)filePath {
- DCHECK([[NSFileManager defaultManager] fileExistsAtPath:filePath]);
- NSData* data = [NSData dataWithContentsOfFile:filePath];
- [_webView loadData:data
- MIMEType:@"application/pdf"
- textEncodingName:@"utf-8"
- baseURL:[NSURL URLWithString:@""]];
-}
-
-- (void)evaluateJavaScript:(NSString*)script
- stringResultHandler:(web::JavaScriptCompletion)handler {
- web::EvaluateJavaScript(_webView, script, handler);
-}
-
-#pragma mark -
-#pragma mark UIWebViewDelegateMethods
-
-- (BOOL)webView:(UIWebView*)webView
- shouldStartLoadWithRequest:(NSURLRequest*)request
- navigationType:(UIWebViewNavigationType)navigationType {
- if ([_delegate respondsToSelector:@selector(simpleWebViewController:
- shouldStartLoadWithRequest:)]) {
- return [_delegate simpleWebViewController:self
- shouldStartLoadWithRequest:request];
- }
- // By default all loads are allowed.
- return YES;
-}
-
-- (void)webViewDidFinishLoad:(UIWebView*)webView {
- if (![_delegate respondsToSelector:@selector(simpleWebViewController:
- titleMayHaveChanged:)]) {
- return;
- }
- [_delegate simpleWebViewController:self titleMayHaveChanged:self.title];
-}
-
-@end
diff --git a/ios/web/web_state/ui/crw_ui_simple_web_view_controller_unittest.mm b/ios/web/web_state/ui/crw_ui_simple_web_view_controller_unittest.mm
deleted file mode 100644
index 02adc98..0000000
--- a/ios/web/web_state/ui/crw_ui_simple_web_view_controller_unittest.mm
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ios/web/web_state/ui/crw_ui_simple_web_view_controller.h"
-
-#import <UIKit/UIKit.h>
-
-#import "base/mac/scoped_nsobject.h"
-#import "base/test/ios/wait_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/gtest_mac.h"
-#include "testing/platform_test.h"
-#import "third_party/ocmock/OCMock/OCMock.h"
-#include "third_party/ocmock/gtest_support.h"
-
-class CRWUISimpleWebViewControllerTest : public PlatformTest {
- protected:
- void SetUp() override {
- mock_web_view_.reset(
- [[OCMockObject niceMockForClass:[UIWebView class]] retain]);
- simple_web_view_controller_.reset([[CRWUISimpleWebViewController alloc]
- initWithUIWebView:mock_web_view_]);
- }
- base::scoped_nsobject<id> mock_web_view_;
- base::scoped_nsobject<CRWUISimpleWebViewController>
- simple_web_view_controller_;
-};
-
-// Tests to make sure a CRWUISimpleWebViewController correctly sets the backing
-// UIWebView and its delegate.
-TEST_F(CRWUISimpleWebViewControllerTest, Basic) {
- EXPECT_EQ(mock_web_view_.get(), [simple_web_view_controller_ view]);
-}
-
-// Tests that CRWUISimpleWebViewController can correctly retrieve the title from
-// the underlying UIWebView.
-// TODO(shreyasv): Revisit this test if mock HTTP server works for unit tests.
-TEST_F(CRWUISimpleWebViewControllerTest, Title) {
- [[[mock_web_view_ stub] andReturn:@"Steven Wilson"]
- stringByEvaluatingJavaScriptFromString:@"document.title"];
- EXPECT_NSEQ(@"Steven Wilson", [simple_web_view_controller_ title]);
-}
-
-// Tests that CRWUISimpleWebViewController correctly reloads from the underlying
-// UIWebView.
-TEST_F(CRWUISimpleWebViewControllerTest, Reload) {
- [[mock_web_view_ expect] reload];
- [simple_web_view_controller_ reload];
- EXPECT_OCMOCK_VERIFY(mock_web_view_);
-}
-
-// Tests that CRWUISimpleWebViewController correctly returns the WebView's
-// scroll view.
-TEST_F(CRWUISimpleWebViewControllerTest, ScrollView) {
- base::scoped_nsobject<UIScrollView> scrollView([[UIScrollView alloc] init]);
- [[[mock_web_view_ stub] andReturn:scrollView] scrollView];
- EXPECT_EQ(scrollView, [simple_web_view_controller_ scrollView]);
-}
-
-// Tests that CRWUISimpleWebViewController correctly loads a request from the
-// underlying UIWebView.
-TEST_F(CRWUISimpleWebViewControllerTest, LoadRequest) {
- NSURLRequest* request =
- [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]];
- [[mock_web_view_ expect] loadRequest:request];
- [simple_web_view_controller_ loadRequest:request];
- EXPECT_OCMOCK_VERIFY(mock_web_view_);
-}
-
-// Tests that CRWUISimpleWebViewControllerDelegate is correctly informed of a
-// load request.
-TEST_F(CRWUISimpleWebViewControllerTest, ShouldStartLoad) {
- base::scoped_nsobject<id> mockDelegate([[OCMockObject
- niceMockForProtocol:@protocol(CRWSimpleWebViewControllerDelegate)]
- retain]);
- NSURLRequest* request =
- [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]];
- [[mockDelegate expect] simpleWebViewController:simple_web_view_controller_
- shouldStartLoadWithRequest:request];
-
- // Simulate a UIWebViewDelegate callback.
- [static_cast<id<UIWebViewDelegate>>(simple_web_view_controller_.get())
- webView:mock_web_view_
- shouldStartLoadWithRequest:request
- navigationType:UIWebViewNavigationTypeOther];
-
- EXPECT_OCMOCK_VERIFY(mock_web_view_);
-}
-
-// Tests correct JavaScript evaluation.
-TEST_F(CRWUISimpleWebViewControllerTest, JavaScriptEvaluation) {
- NSString* const kTestScript = @"script";
- NSString* const kTestResult = @"result";
- [[[mock_web_view_ stub] andReturn:kTestResult]
- stringByEvaluatingJavaScriptFromString:kTestScript];
-
- __block bool evaluation_completed = false;
- id completion_handler = ^(NSString* result, NSError* error) {
- evaluation_completed = true;
- EXPECT_NSEQ(kTestResult, result);
- EXPECT_EQ(nil, error);
- };
- [simple_web_view_controller_ evaluateJavaScript:kTestScript
- stringResultHandler:completion_handler];
- base::test::ios::WaitUntilCondition(^bool() {
- return evaluation_completed;
- });
-
- EXPECT_OCMOCK_VERIFY(mock_web_view_);
-}