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

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller_egtest.mm

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: build.gn and rebase Created 3 years, 10 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 #include <map> 5 #include <map>
6 6
7 #import <EarlGrey/EarlGrey.h> 7 #import <EarlGrey/EarlGrey.h>
8 #import <WebKit/WebKit.h> 8 #import <WebKit/WebKit.h>
9 #import <XCTest/XCTest.h> 9 #import <XCTest/XCTest.h>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 web::test::HttpServer::MakeUrl("http://destination"); 43 web::test::HttpServer::MakeUrl("http://destination");
44 responses[startURL] = "Start"; 44 responses[startURL] = "Start";
45 responses[destinationURL] = "You've arrived!"; 45 responses[destinationURL] = "You've arrived!";
46 web::test::SetUpSimpleHttpServer(responses); 46 web::test::SetUpSimpleHttpServer(responses);
47 47
48 // Just load the first URL. 48 // Just load the first URL.
49 [ChromeEarlGrey loadURL:startURL]; 49 [ChromeEarlGrey loadURL:startURL];
50 50
51 // Waits for the page to load and check it is the expected content. 51 // Waits for the page to load and check it is the expected content.
52 id<GREYMatcher> responseMatcher = 52 id<GREYMatcher> responseMatcher =
53 chrome_test_util::webViewContainingText(responses[startURL]); 53 chrome_test_util::WebViewContainingText(responses[startURL]);
54 [[EarlGrey selectElementWithMatcher:responseMatcher] 54 [[EarlGrey selectElementWithMatcher:responseMatcher]
55 assertWithMatcher:grey_notNil()]; 55 assertWithMatcher:grey_notNil()];
56 56
57 // In the omnibox, the URL should be present, without the http:// prefix. 57 // In the omnibox, the URL should be present, without the http:// prefix.
58 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 58 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
59 assertWithMatcher:chrome_test_util::omniboxText(startURL.GetContent())]; 59 assertWithMatcher:chrome_test_util::OmniboxText(startURL.GetContent())];
60 60
61 // Types some javascript in the omnibox to trigger a navigation. 61 // Types some javascript in the omnibox to trigger a navigation.
62 NSString* script = 62 NSString* script =
63 [NSString stringWithFormat:@"javascript:location.href='%s'\n", 63 [NSString stringWithFormat:@"javascript:location.href='%s'\n",
64 destinationURL.spec().c_str()]; 64 destinationURL.spec().c_str()];
65 65
66 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 66 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
67 performAction:grey_typeText(script)]; 67 performAction:grey_typeText(script)];
68 68
69 // In the omnibox, the new URL should be present, without the http:// prefix. 69 // In the omnibox, the new URL should be present, without the http:// prefix.
70 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] 70 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
71 assertWithMatcher:chrome_test_util::omniboxText( 71 assertWithMatcher:chrome_test_util::OmniboxText(
72 destinationURL.GetContent())]; 72 destinationURL.GetContent())];
73 73
74 // Verifies that the navigation to the destination page happened. 74 // Verifies that the navigation to the destination page happened.
75 GREYAssertEqual(destinationURL, 75 GREYAssertEqual(destinationURL,
76 chrome_test_util::GetCurrentWebState()->GetVisibleURL(), 76 chrome_test_util::GetCurrentWebState()->GetVisibleURL(),
77 @"Did not navigate to the destination url."); 77 @"Did not navigate to the destination url.");
78 78
79 // Verifies that the destination page is shown. 79 // Verifies that the destination page is shown.
80 id<GREYMatcher> navigationMatcher = 80 id<GREYMatcher> navigationMatcher =
81 chrome_test_util::webViewContainingText(responses[destinationURL]); 81 chrome_test_util::WebViewContainingText(responses[destinationURL]);
82 [[EarlGrey selectElementWithMatcher:grey_kindOfClass([WKWebView class])] 82 [[EarlGrey selectElementWithMatcher:grey_kindOfClass([WKWebView class])]
83 assertWithMatcher:navigationMatcher]; 83 assertWithMatcher:navigationMatcher];
84 } 84 }
85 85
86 @end 86 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmarks_egtest.mm ('k') | ios/chrome/browser/ui/dialogs/javascript_dialog_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698