Commit 2fbb923b authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Revert "[ios] Convert web view shell EarlGrey matchers to ObjC"

This reverts commit 6a083248.

Reason for revert: Caused build failure on ios-webview. See https://ci.chromium.org/p/chromium/builders/ci/ios-webview/6881 

Original change's description:
> [ios] Convert web view shell EarlGrey matchers to ObjC
> 
> We need to port matchers to ObjC in order to be accessible in EG2 to
> the Test and the App processes. Also created
> shell_matchers_shorthand.h/mm to minimize the changes to call sites.
> 
> Bug: 930859
> Change-Id: Ia4a4ba8c7dd3b805600ea0c46c5b737a8282189d
> Reviewed-on: https://chromium-review.googlesource.com/c/1471914
> Commit-Queue: Lindsay Pasricha <lindsayw@chromium.org>
> Reviewed-by: Rohit Rao <rohitrao@chromium.org>
> Reviewed-by: Eugene But <eugenebut@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#636214}

TBR=rohitrao@chromium.org,justincohen@chromium.org,eugenebut@chromium.org,lindsayw@chromium.org

Change-Id: Ia25eed2c0bc83fd3749543b9a3ddd75fc90c1942
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 930859
Reviewed-on: https://chromium-review.googlesource.com/c/1491738Reviewed-by: default avatarRakina Zata Amni <rakina@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636222}
parent 32fe14d4
......@@ -87,8 +87,6 @@ source_set("earl_grey_test_support") {
"earl_grey/shell_earl_grey.mm",
"earl_grey/shell_matchers.h",
"earl_grey/shell_matchers.mm",
"earl_grey/shell_matchers_shorthand.h",
"earl_grey/shell_matchers_shorthand.mm",
"earl_grey/web_shell_test_case.h",
"earl_grey/web_shell_test_case.mm",
]
......
......@@ -18,7 +18,6 @@
#import "ios/web/shell/test/earl_grey/shell_actions.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#import "ios/web/shell/test/earl_grey/shell_matchers_shorthand.h"
#import "ios/web/shell/test/earl_grey/web_shell_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......
......@@ -5,34 +5,30 @@
#ifndef IOS_WEB_SHELL_TEST_EARL_GREY_SHELL_MATCHERS_H_
#define IOS_WEB_SHELL_TEST_EARL_GREY_SHELL_MATCHERS_H_
#import <Foundation/Foundation.h>
#include <string>
// ObjC matcher class for use in EG2 tests (Test and App process).
// Shell_matchers_shorthand.h/mm is C++ and for use when writing EG1 tests.
@protocol GREYMatcher;
#import <EarlGrey/EarlGrey.h>
@interface ShellMatchers : NSObject
namespace web {
// Matcher for the WKWebView.
+ (id<GREYMatcher>)webView;
id<GREYMatcher> WebView();
// Matcher for WKWebView's scroll view.
+ (id<GREYMatcher>)webViewScrollView;
id<GREYMatcher> WebViewScrollView();
// Matcher for web shell address field text property equal to |text|.
+ (id<GREYMatcher>)addressFieldWithText:(NSString*)text;
id<GREYMatcher> AddressFieldText(std::string text);
// Matcher for back button in web shell.
+ (id<GREYMatcher>)backButton;
id<GREYMatcher> BackButton();
// Matcher for forward button in web shell.
+ (id<GREYMatcher>)forwardButton;
id<GREYMatcher> ForwardButton();
// Matcher for address field in web shell.
+ (id<GREYMatcher>)addressField;
id<GREYMatcher> AddressField();
@end
} // namespace web
#endif // IOS_WEB_SHELL_TEST_EARL_GREY_SHELL_MATCHERS_H_
......@@ -17,17 +17,17 @@
#error "This file requires ARC support."
#endif
@implementation ShellMatchers
namespace web {
+ (id<GREYMatcher>)webView {
return WebViewInWebState(web::shell_test_util::GetCurrentWebState());
id<GREYMatcher> WebView() {
return WebViewInWebState(shell_test_util::GetCurrentWebState());
}
+ (id<GREYMatcher>)webViewScrollView {
return WebViewScrollView(web::shell_test_util::GetCurrentWebState());
id<GREYMatcher> WebViewScrollView() {
return WebViewScrollView(shell_test_util::GetCurrentWebState());
}
+ (id<GREYMatcher>)addressFieldWithText:(NSString*)text {
id<GREYMatcher> AddressFieldText(std::string text) {
MatchesBlock matches = ^BOOL(UIView* view) {
if (![view isKindOfClass:[UITextField class]]) {
return NO;
......@@ -39,12 +39,12 @@
UITextField* text_field = base::mac::ObjCCastStrict<UITextField>(view);
NSString* error_message = [NSString
stringWithFormat:
@"Address field text did not match. expected: %@, actual: %@", text,
text_field.text];
@"Address field text did not match. expected: %@, actual: %@",
base::SysUTF8ToNSString(text), text_field.text];
GREYAssert(base::test::ios::WaitUntilConditionOrTimeout(
base::test::ios::kWaitForUIElementTimeout,
^{
return [text_field.text isEqualToString:text];
return base::SysNSStringToUTF8(text_field.text) == text;
}),
error_message);
return YES;
......@@ -52,23 +52,23 @@
DescribeToBlock describe = ^(id<GREYDescription> description) {
[description appendText:@"address field containing "];
[description appendText:text];
[description appendText:base::SysUTF8ToNSString(text)];
};
return [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
descriptionBlock:describe];
}
+ (id<GREYMatcher>)backButton {
id<GREYMatcher> BackButton() {
return grey_accessibilityLabel(kWebShellBackButtonAccessibilityLabel);
}
+ (id<GREYMatcher>)forwardButton {
id<GREYMatcher> ForwardButton() {
return grey_accessibilityLabel(kWebShellForwardButtonAccessibilityLabel);
}
+ (id<GREYMatcher>)addressField {
id<GREYMatcher> AddressField() {
return grey_accessibilityLabel(kWebShellAddressFieldAccessibilityLabel);
}
@end
} // namespace web
// Copyright 2019 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_SHELL_TEST_EARL_GREY_SHELL_MATCHERS_SHORTHAND_H_
#define IOS_WEB_SHELL_TEST_EARL_GREY_SHELL_MATCHERS_SHORTHAND_H_
#import <Foundation/Foundation.h>
#include <string>
// Matchers for use in EG1 tests and in EG2 App Process.
@protocol GREYMatcher;
namespace web {
// Matcher for the WKWebView.
id<GREYMatcher> WebView();
// Matcher for WKWebView's scroll view.
id<GREYMatcher> WebViewScrollView();
// Matcher for web shell address field text property equal to |text|.
id<GREYMatcher> AddressFieldText(std::string text);
// Matcher for back button in web shell.
id<GREYMatcher> BackButton();
// Matcher for forward button in web shell.
id<GREYMatcher> ForwardButton();
// Matcher for address field in web shell.
id<GREYMatcher> AddressField();
} // namespace web
#endif // IOS_WEB_SHELL_TEST_EARL_GREY_SHELL_MATCHERS_SHORTHAND_H_
// Copyright 2019 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 <EarlGrey/EarlGrey.h>
#import <WebKit/WebKit.h>
#include "base/strings/sys_string_conversions.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#import "ios/web/shell/test/earl_grey/shell_matchers_shorthand.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace web {
id<GREYMatcher> WebView() {
return [ShellMatchers webView];
}
id<GREYMatcher> WebViewScrollView() {
return [ShellMatchers webViewScrollView];
}
id<GREYMatcher> AddressFieldText(std::string text) {
return [ShellMatchers addressFieldWithText:base::SysUTF8ToNSString(text)];
}
id<GREYMatcher> BackButton() {
return [ShellMatchers backButton];
}
id<GREYMatcher> ForwardButton() {
return [ShellMatchers forwardButton];
}
id<GREYMatcher> AddressField() {
return [ShellMatchers addressField];
}
} // namespace web
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <EarlGrey/EarlGrey.h>
#include <map>
#include "base/strings/stringprintf.h"
......@@ -12,7 +10,6 @@
#include "ios/web/public/test/http_server/http_server_util.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#import "ios/web/shell/test/earl_grey/shell_matchers_shorthand.h"
#import "ios/web/shell/test/earl_grey/web_shell_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......
......@@ -12,7 +12,6 @@
#include "ios/web/public/test/http_server/http_server_util.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#import "ios/web/shell/test/earl_grey/shell_matchers_shorthand.h"
#import "ios/web/shell/test/earl_grey/web_shell_test_case.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......
......@@ -10,7 +10,6 @@
#include "ios/web/public/test/http_server/http_server_util.h"
#import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
#import "ios/web/shell/test/earl_grey/shell_matchers.h"
#import "ios/web/shell/test/earl_grey/shell_matchers_shorthand.h"
#import "ios/web/shell/test/earl_grey/web_shell_test_case.h"
#include "net/http/http_status_code.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment