summaryrefslogtreecommitdiffstats
path: root/ios/web/test
diff options
context:
space:
mode:
authoreugenebut <eugenebut@chromium.org>2016-02-25 09:23:33 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-25 17:24:33 +0000
commit0d0f570bc1b65bd450c044e3c1b229bc0f8a65b1 (patch)
tree5a476435947441bbd9d489a2188045146a6add82 /ios/web/test
parent5e08f8e808426c2d22ca528c6efbae0234d6ebde (diff)
downloadchromium_src-0d0f570bc1b65bd450c044e3c1b229bc0f8a65b1.zip
chromium_src-0d0f570bc1b65bd450c044e3c1b229bc0f8a65b1.tar.gz
chromium_src-0d0f570bc1b65bd450c044e3c1b229bc0f8a65b1.tar.bz2
[ios] Removed UIWebView support from web_test.
Removed various code like: WebTest::MessageQueueIsEmpty TestWebController class WebTestWithUIWebViewWebController class BUG=579697 Review URL: https://codereview.chromium.org/1737493003 Cr-Commit-Position: refs/heads/master@{#377600}
Diffstat (limited to 'ios/web/test')
-rw-r--r--ios/web/test/web_test.h48
-rw-r--r--ios/web/test/web_test.mm77
2 files changed, 14 insertions, 111 deletions
diff --git a/ios/web/test/web_test.h b/ios/web/test/web_test.h
index 46bdbca..d7a369b 100644
--- a/ios/web/test/web_test.h
+++ b/ios/web/test/web_test.h
@@ -7,6 +7,7 @@
#import <UIKit/UIKit.h>
+#import "base/ios/block_types.h"
#import "base/mac/scoped_nsobject.h"
#include "base/message_loop/message_loop.h"
#include "ios/web/public/test/scoped_testing_web_client.h"
@@ -14,22 +15,9 @@
#import "ios/web/public/test/test_web_client.h"
#include "ios/web/public/test/test_web_thread_bundle.h"
#include "ios/web/public/web_client.h"
-#import "ios/web/web_state/ui/crw_ui_web_view_web_controller.h"
+#import "ios/web/web_state/ui/crw_web_controller.h"
#include "testing/platform_test.h"
-// A subclass of WebController overridden for testing purposes. Specifically it
-// overrides the UIWebView delegate method to intercept requests coming from
-// core.js.
-// TODO(jimblackler): remove use of TestWebController entirely.
-@interface TestWebController : CRWUIWebViewWebController
-
-@property(nonatomic, assign) BOOL interceptRequest;
-@property(nonatomic, assign) BOOL requestIntercepted;
-@property(nonatomic, assign) BOOL
- invokeShouldStartLoadWithRequestNavigationTypeDone;
-
-@end
-
namespace web {
// A test fixture for web tests that need a minimum environment set up that
@@ -87,10 +75,6 @@ class WebTestWithWebController : public WebTest,
// Blocks until known NSRunLoop-based have completed, known message-loop-based
// background tasks have completed and |condition| evaluates to true.
void WaitForCondition(ConditionBlock condition);
- // Returns true if WebController message queue is empty.
- // |WaitForBackgroundTasks| does not return until until the message queue is
- // empty.
- bool MessageQueueIsEmpty() const;
// Evaluates JavaScript and returns result as a string.
NSString* EvaluateJavaScriptAsString(NSString* script) const;
// Runs the given JavaScript and returns the result as a string. This method
@@ -98,8 +82,8 @@ class WebTestWithWebController : public WebTest,
// the additional functionality that any JavaScript exceptions are caught and
// logged (not dropped silently).
NSString* RunJavaScript(NSString* script);
- // Returns a CRWWebController to be used in tests.
- virtual CRWWebController* CreateWebController() = 0;
+ // Creates a CRWWebController to be used in tests.
+ virtual CRWWebController* CreateWebController();
// TaskObserver methods (used when waiting for background tasks).
void WillProcessTask(const base::PendingTask& pending_task) override;
void DidProcessTask(const base::PendingTask& pending_task) override;
@@ -122,28 +106,10 @@ class WebTestWithWebController : public WebTest,
#pragma mark -
-// A test fixtures thats creates a CRWUIWebViewWebController for testing.
-class WebTestWithUIWebViewWebController : public WebTestWithWebController {
- protected:
- // WebTestWithWebController methods.
- CRWWebController* CreateWebController() override;
-
- // Invokes JS->ObjC messages directly on the web controller, registering a
- // human interaction if userIsInteraction==YES. |commands| should be a
- // stringified message queue.
- void LoadCommands(NSString* commands,
- const GURL& origin_url,
- BOOL user_is_interacting);
-};
-
-#pragma mark -
-
// A test fixtures thats creates a CRWWKWebViewWebController for testing.
-class WebTestWithWKWebViewWebController : public WebTestWithWebController {
- protected:
- // WebTestWithWebController methods.
- CRWWebController* CreateWebController() override;
-};
+// TODO(crbug.com/589563): Remove this typedef, clients should use
+// |WebTestWithWebController|.
+typedef WebTestWithWebController WebTestWithWKWebViewWebController;
} // namespace web
diff --git a/ios/web/test/web_test.mm b/ios/web/test/web_test.mm
index f6c781c..5d2bee2 100644
--- a/ios/web/test/web_test.mm
+++ b/ios/web/test/web_test.mm
@@ -15,7 +15,6 @@
#include "ios/web/public/active_state_manager.h"
#include "ios/web/public/referrer.h"
#import "ios/web/public/web_state/ui/crw_web_delegate.h"
-#import "ios/web/web_state/js/crw_js_invoke_parameter_queue.h"
#import "ios/web/web_state/ui/crw_wk_web_view_web_controller.h"
#import "ios/web/web_state/web_state_impl.h"
#include "third_party/ocmock/OCMock/OCMock.h"
@@ -148,7 +147,7 @@ void WebTestWithWebController::WaitForBackgroundTasks() {
if (processed_a_task_) // Set in TaskObserver method.
activitySeen = true;
- } while (activitySeen || !MessageQueueIsEmpty());
+ } while (activitySeen);
messageLoop->RemoveTaskObserver(this);
}
@@ -159,15 +158,6 @@ void WebTestWithWebController::WaitForCondition(ConditionBlock condition) {
base::TimeDelta::FromSeconds(10));
}
-bool WebTestWithWebController::MessageQueueIsEmpty() const {
- // Using this check rather than polymorphism because polymorphising
- // Chrome*WebViewWebTest would be overengineering. Chrome*WebViewWebTest
- // inherits from WebTestWithWebController.
- return [webController_ webViewType] == web::WK_WEB_VIEW_TYPE ||
- [static_cast<CRWUIWebViewWebController*>(webController_)
- jsInvokeParameterQueue].isEmpty;
-}
-
NSString* WebTestWithWebController::EvaluateJavaScriptAsString(
NSString* script) const {
__block base::scoped_nsobject<NSString> evaluationResult;
@@ -233,6 +223,12 @@ NSString* WebTestWithWebController::RunJavaScript(NSString* script) {
return [dictionary objectForKey:@"result"];
}
+CRWWebController* WebTestWithWebController::CreateWebController() {
+ scoped_ptr<WebStateImpl> web_state_impl(new WebStateImpl(GetBrowserState()));
+ return [[CRWWKWebViewWebController alloc]
+ initWithWebState:std::move(web_state_impl)];
+}
+
void WebTestWithWebController::WillProcessTask(
const base::PendingTask& pending_task) {
// Nothing to do.
@@ -261,63 +257,4 @@ NSString* WebTestWithWebController::CreateLoadCheck() {
s_html_load_count++];
}
-#pragma mark -
-
-CRWWebController* WebTestWithUIWebViewWebController::CreateWebController() {
- scoped_ptr<WebStateImpl> web_state_impl(new WebStateImpl(GetBrowserState()));
- return [[TestWebController alloc] initWithWebState:std::move(web_state_impl)];
-}
-
-void WebTestWithUIWebViewWebController::LoadCommands(NSString* commands,
- const GURL& origin_url,
- BOOL user_is_interacting) {
- [static_cast<CRWUIWebViewWebController*>(webController_)
- respondToMessageQueue:commands
- userIsInteracting:user_is_interacting
- originURL:origin_url];
-}
-
-#pragma mark -
-
-CRWWebController* WebTestWithWKWebViewWebController::CreateWebController() {
- scoped_ptr<WebStateImpl> web_state_impl(new WebStateImpl(GetBrowserState()));
- return [[CRWWKWebViewWebController alloc]
- initWithWebState:std::move(web_state_impl)];
-}
-
} // namespace web
-
-#pragma mark -
-
-// Declare CRWUIWebViewWebController's (private) implementation of
-// UIWebViewDelegate.
-@interface CRWUIWebViewWebController(TestProtocolDeclaration)<UIWebViewDelegate>
-@end
-
-@implementation TestWebController {
- BOOL _interceptRequest;
- BOOL _requestIntercepted;
- BOOL _invokeShouldStartLoadWithRequestNavigationTypeDone;
-}
-
-@synthesize interceptRequest = _interceptRequest;
-@synthesize requestIntercepted = _requestIntercepted;
-@synthesize invokeShouldStartLoadWithRequestNavigationTypeDone =
- _invokeShouldStartLoadWithRequestNavigationTypeDone;
-
-- (BOOL)webView:(UIWebView*)webView
- shouldStartLoadWithRequest:(NSURLRequest*)request
- navigationType:(UIWebViewNavigationType)navigationType {
- _invokeShouldStartLoadWithRequestNavigationTypeDone = false;
- // Conditionally block the request to open a webpage.
- if (_interceptRequest) {
- _requestIntercepted = true;
- return false;
- }
- BOOL result = [super webView:webView
- shouldStartLoadWithRequest:request
- navigationType:navigationType];
- _invokeShouldStartLoadWithRequestNavigationTypeDone = true;
- return result;
-}
-@end