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

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: s/include/import 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
« no previous file with comments | « ios/web/shell/test/shell_matchers.mm ('k') | ios/web/shell/test/web_shell_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..24d10258a224f816a82b3008c70a899a5a686506 100644
--- a/ios/web/shell/test/web_shell_navigation_egtest.mm
+++ b/ios/web/shell/test/web_shell_navigation_egtest.mm
@@ -3,63 +3,86 @@
// found in the LICENSE file.
#import <UIKit/UIKit.h>
+#import <WebKit/WebKit.h>
#import <XCTest/XCTest.h>
#import <EarlGrey/EarlGrey.h>
-#import "ios/web/shell/view_controller.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/navigation_test_util.h"
+#import "ios/web/shell/test/shell_matchers.h"
+#import "ios/web/shell/test/web_view_matchers.h"
+// Navigation test cases for the web shell. These are Earl Grey integration
+// tests, which are based on XCTest.
@interface CRWWebShellNavigationTest : XCTestCase
@end
@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());
}
-// Sample test to load a live URL, go back, forward, and then back again.
-- (void)testExternalURLBackAndForwardAndBack {
- [[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)]
+// 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();
+}
+
+// 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 URL1 = web::test::HttpServer::MakeUrl("http://firstURL");
+ NSString* response1 = @"Test Page 1";
+ responses[URL1] = base::SysNSStringToUTF8(response1);
+
+ const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL");
+ NSString* response2 = @"Test Page 2";
+ responses[URL2] = base::SysNSStringToUTF8(response2);
+
+ web::test::SetUpSimpleHttpServer(responses);
+
+ web::navigation_test_util::LoadUrl(URL1);
+
+ [[EarlGrey selectElementWithMatcher:shell_webViewContainingText(response1)]
+ assertWithMatcher:grey_notNil()];
+
+ web::navigation_test_util::LoadUrl(URL2);
+
+ [[EarlGrey selectElementWithMatcher:shell_webViewContainingText(response2)]
+ assertWithMatcher:grey_notNil()];
+
+ [[EarlGrey selectElementWithMatcher:shell_backButton()]
performAction:grey_tap()];
- [[EarlGrey
- selectElementWithMatcher:grey_accessibilityLabel(
- kWebShellBackButtonAccessibilityLabel)]
+
+ [[EarlGrey selectElementWithMatcher:shell_webViewContainingText(response1)]
+ assertWithMatcher:grey_notNil()];
+
+ [[EarlGrey selectElementWithMatcher:shell_forwardButton()]
performAction:grey_tap()];
+
+ [[EarlGrey selectElementWithMatcher:shell_webViewContainingText(response2)]
+ assertWithMatcher:grey_notNil()];
}
+
@end
« no previous file with comments | « ios/web/shell/test/shell_matchers.mm ('k') | ios/web/shell/test/web_shell_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698