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

Unified Diff: ios/web/shell/test/web_shell_navigation_egtest.mm

Issue 1890333002: Web shell test to go back and forward. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make webState a property Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/shell/test/web_shell_navigation_egtest.mm
diff --git a/ios/web/shell/test/web_shell_navigation_egtest.mm b/ios/web/shell/test/web_shell_navigation_egtest.mm
index 38936aecbe8e41e3afd7e501e2542f321e2b89c4..1e11ac29daba8d923a2ee10b1e4991b87f0cc373 100644
--- a/ios/web/shell/test/web_shell_navigation_egtest.mm
+++ b/ios/web/shell/test/web_shell_navigation_egtest.mm
@@ -3,10 +3,16 @@
// found in the LICENSE file.
#import <UIKit/UIKit.h>
+#import <WebKit/WebKit.h>
#import <XCTest/XCTest.h>
#import <EarlGrey/EarlGrey.h>
+#include "base/strings/sys_string_conversions.h"
+#import "ios/web/public/test/http_server.h"
+#include "ios/web/public/test/http_server_util.h"
+#include "ios/web/shell/test/utils/navigation_egutil.h"
+#import "ios/web/shell/test/utils/web_view_egutil.h"
#import "ios/web/shell/view_controller.h"
@interface CRWWebShellNavigationTest : XCTestCase
Eugene But (OOO till 7-30) 2016/04/21 17:07:56 From Style Guide: Every non-trivial interface, pub
baxley 2016/04/21 21:52:52 Done.
@@ -15,51 +21,72 @@
@implementation CRWWebShellNavigationTest
-// Sample test to load a live URL, go back and then forward.
-- (void)testExternalURLBackAndForward {
- [[EarlGrey
- selectElementWithMatcher:grey_accessibilityLabel(
- kWebShellAddressFieldAccessibilityLabel)]
- performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Clear text")]
- performAction:grey_tap()];
- [[EarlGrey
- selectElementWithMatcher:grey_accessibilityLabel(
- kWebShellAddressFieldAccessibilityLabel)]
- performAction:grey_typeText(@"http://browsingtest.appspot.com\n")];
- [[EarlGrey
- selectElementWithMatcher:grey_accessibilityLabel(
- kWebShellBackButtonAccessibilityLabel)]
- performAction:grey_tap()];
- [[EarlGrey
- selectElementWithMatcher:grey_accessibilityLabel(
- kWebShellForwardButtonAccessibilityLabel)]
- performAction:grey_tap()];
+// Set up called once for the class.
++ (void)setUp {
+ [super setUp];
+ [[EarlGrey selectElementWithMatcher:shell_webViewContainingText(@"Chromium")]
+ assertWithMatcher:grey_notNil()];
+ web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
+ server.StartOrDie();
+ DCHECK(server.IsRunning());
+}
+
+// Tear down called once for the class.
++ (void)tearDown {
+ [super tearDown];
+ web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
+ server.Stop();
+ DCHECK(!server.IsRunning());
+}
+
+// Tear down called after each test.
+- (void)tearDown {
+ [super tearDown];
+ web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
+ server.RemoveAllResponseProviders();
}
-// Sample test to load a live URL, go back, forward, and then back again.
-- (void)testExternalURLBackAndForwardAndBack {
+// Tests the back and forward button after entering two URLs.
+- (void)testWebScenarioBrowsingBackAndForward {
+ // Create map of canned responses and set up the test HTML server.
+ std::map<GURL, std::string> responses;
+ const GURL firstURL = web::test::HttpServer::MakeUrl("http://firstURL");
+ NSString* firstResponse = @"Test Page 1";
+ responses[firstURL] = base::SysNSStringToUTF8(firstResponse);
+
+ const GURL secondURL = web::test::HttpServer::MakeUrl("http://secondURL");
+ NSString* secondResponse = @"Test Page 2";
+ responses[secondURL] = base::SysNSStringToUTF8(secondResponse);
+
+ web::test::SetUpSimpleHttpServer(responses);
+
+ navigation_egutil::LoadURL(firstURL);
+
[[EarlGrey
- selectElementWithMatcher:grey_accessibilityLabel(
- kWebShellAddressFieldAccessibilityLabel)]
- performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Clear text")]
- performAction:grey_tap()];
+ selectElementWithMatcher:shell_webViewContainingText(firstResponse)]
+ assertWithMatcher:grey_notNil()];
+
+ navigation_egutil::LoadURL(secondURL);
+
[[EarlGrey
- selectElementWithMatcher:grey_accessibilityLabel(
- kWebShellAddressFieldAccessibilityLabel)]
- performAction:grey_typeText(@"http://browsingtest.appspot.com\n")];
+ selectElementWithMatcher:shell_webViewContainingText(secondResponse)]
+ assertWithMatcher:grey_notNil()];
+
[[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(
Eugene But (OOO till 7-30) 2016/04/21 17:07:56 This formatting does not look readable. How about
baxley 2016/04/21 21:52:52 Done.
kWebShellBackButtonAccessibilityLabel)]
performAction:grey_tap()];
[[EarlGrey
+ selectElementWithMatcher:shell_webViewContainingText(firstResponse)]
+ assertWithMatcher:grey_notNil()];
+ [[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(
Eugene But (OOO till 7-30) 2016/04/21 17:07:56 ditto
baxley 2016/04/21 21:52:52 Done.
kWebShellForwardButtonAccessibilityLabel)]
performAction:grey_tap()];
+
[[EarlGrey
- selectElementWithMatcher:grey_accessibilityLabel(
- kWebShellBackButtonAccessibilityLabel)]
- performAction:grey_tap()];
+ selectElementWithMatcher:shell_webViewContainingText(secondResponse)]
+ assertWithMatcher:grey_notNil()];
}
+
@end

Powered by Google App Engine
This is Rietveld 408576698