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

Side by Side Diff: ios/web/shell/test/web_shell_navigation_egtest.mm

Issue 1950323002: Refactor web shell integration tests utilities. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up import/include Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
6 #import <WebKit/WebKit.h> 6 #import <WebKit/WebKit.h>
7 #import <XCTest/XCTest.h> 7 #import <XCTest/XCTest.h>
8 8
9 #import <EarlGrey/EarlGrey.h> 9 #import <EarlGrey/EarlGrey.h>
10 10
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #import "ios/web/public/test/earl_grey/web_view_matchers.h"
12 #import "ios/web/public/test/http_server.h" 13 #import "ios/web/public/test/http_server.h"
13 #include "ios/web/public/test/http_server_util.h" 14 #include "ios/web/public/test/http_server_util.h"
14 #include "ios/web/shell/test/navigation_test_util.h" 15 #include "ios/web/public/test/navigation_test_util.h"
15 #import "ios/web/shell/test/shell_matchers.h" 16 #include "ios/web/shell/test/app/web_shell_test_util.h"
16 #import "ios/web/shell/test/web_view_matchers.h" 17 #import "ios/web/shell/test/earl_grey/shell_matchers.h"
17 18
18 // Navigation test cases for the web shell. These are Earl Grey integration 19 // Navigation test cases for the web shell. These are Earl Grey integration
19 // tests, which are based on XCTest. 20 // tests, which are based on XCTest.
20 @interface CRWWebShellNavigationTest : XCTestCase 21 @interface CRWWebShellNavigationTest : XCTestCase
21 22
22 @end 23 @end
23 24
24 @implementation CRWWebShellNavigationTest 25 @implementation CRWWebShellNavigationTest
25 26
26 // Set up called once for the class. 27 // Set up called once for the class.
27 + (void)setUp { 28 + (void)setUp {
28 [super setUp]; 29 [super setUp];
29 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(@"Chromium")] 30 web::WebState* webState = web::web_shell_test_util::GetCurrentWebState();
31 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(@"Chromium",
32 webState)]
30 assertWithMatcher:grey_notNil()]; 33 assertWithMatcher:grey_notNil()];
31 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); 34 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
32 server.StartOrDie(); 35 server.StartOrDie();
33 DCHECK(server.IsRunning()); 36 DCHECK(server.IsRunning());
34 } 37 }
35 38
36 // Tear down called once for the class. 39 // Tear down called once for the class.
37 + (void)tearDown { 40 + (void)tearDown {
38 [super tearDown]; 41 [super tearDown];
39 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); 42 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
(...skipping 15 matching lines...) Expand all
55 const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL"); 58 const GURL URL1 = web::test::HttpServer::MakeUrl("http://firstURL");
56 NSString* response1 = @"Test Page 1"; 59 NSString* response1 = @"Test Page 1";
57 responses[URL1] = base::SysNSStringToUTF8(response1); 60 responses[URL1] = base::SysNSStringToUTF8(response1);
58 61
59 const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL"); 62 const GURL URL2 = web::test::HttpServer::MakeUrl("http://secondURL");
60 NSString* response2 = @"Test Page 2"; 63 NSString* response2 = @"Test Page 2";
61 responses[URL2] = base::SysNSStringToUTF8(response2); 64 responses[URL2] = base::SysNSStringToUTF8(response2);
62 65
63 web::test::SetUpSimpleHttpServer(responses); 66 web::test::SetUpSimpleHttpServer(responses);
64 67
65 web::navigation_test_util::LoadUrl(URL1); 68 web::WebState* webState = web::web_shell_test_util::GetCurrentWebState();
66 69
67 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] 70 web::navigation_test_util::LoadUrl(webState, URL1);
71
72 [[EarlGrey
73 selectElementWithMatcher:web::webViewContainingText(response1, webState)]
Eugene But (OOO till 7-30) 2016/05/05 18:01:11 Can you keep the old web::webViewContainingText(NS
baxley 2016/05/05 18:33:18 Just to clarify, you're suggesting to have (I shor
Eugene But (OOO till 7-30) 2016/05/05 18:50:32 Correct. |shellMatcher(text)| implementation will
baxley 2016/05/05 21:13:53 Done.
68 assertWithMatcher:grey_notNil()]; 74 assertWithMatcher:grey_notNil()];
69 75
70 web::navigation_test_util::LoadUrl(URL2); 76 web::navigation_test_util::LoadUrl(webState, URL2);
71 77
72 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] 78 [[EarlGrey
79 selectElementWithMatcher:web::webViewContainingText(response2, webState)]
73 assertWithMatcher:grey_notNil()]; 80 assertWithMatcher:grey_notNil()];
74 81
75 [[EarlGrey selectElementWithMatcher:web::backButton()] 82 //[[EarlGrey selectElementWithMatcher:web::backButton()]
83 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Back")]
Eugene But (OOO till 7-30) 2016/05/05 18:01:11 Why? Old code was more readable and shorter.
baxley 2016/05/05 18:33:18 This was inadvertent, I thought I was editing a di
baxley 2016/05/05 21:13:53 Done.
76 performAction:grey_tap()]; 84 performAction:grey_tap()];
77 85
78 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response1)] 86 [[EarlGrey
87 selectElementWithMatcher:web::webViewContainingText(response1, webState)]
79 assertWithMatcher:grey_notNil()]; 88 assertWithMatcher:grey_notNil()];
80 89
81 [[EarlGrey selectElementWithMatcher:web::forwardButton()] 90 //[[EarlGrey selectElementWithMatcher:web::forwardButton()]
91 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Forward")]
82 performAction:grey_tap()]; 92 performAction:grey_tap()];
83 93
84 [[EarlGrey selectElementWithMatcher:web::webViewContainingText(response2)] 94 [[EarlGrey
95 selectElementWithMatcher:web::webViewContainingText(response2, webState)]
85 assertWithMatcher:grey_notNil()]; 96 assertWithMatcher:grey_notNil()];
86 } 97 }
87 98
88 @end 99 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698