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

Side by Side Diff: ios/chrome/browser/translate/translate_egtest.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: review comments Created 3 years, 6 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 <XCTest/XCTest.h> 5 #import <XCTest/XCTest.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/mac/bind_objc_block.h" 8 #include "base/mac/bind_objc_block.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 770
771 // Wait for all callbacks. 771 // Wait for all callbacks.
772 GREYAssert(testing::WaitUntilConditionOrTimeout( 772 GREYAssert(testing::WaitUntilConditionOrTimeout(
773 testing::kWaitForJSCompletionTimeout, 773 testing::kWaitForJSCompletionTimeout,
774 ^{ 774 ^{
775 return jsTranslateManager.translateStatusChecked; 775 return jsTranslateManager.translateStatusChecked;
776 }), 776 }),
777 @"Did not receive all translate status callbacks"); 777 @"Did not receive all translate status callbacks");
778 778
779 // Check that the translation happened. 779 // Check that the translation happened.
780 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 780 [ChromeEarlGrey waitForWebViewContainingText:"Translated"];
781 "Translated")]
782 assertWithMatcher:grey_notNil()];
783 781
784 // Click on the link. 782 // Click on the link.
785 [ChromeEarlGrey tapWebViewElementWithID:@"link"]; 783 [ChromeEarlGrey tapWebViewElementWithID:@"link"];
786 GURL frenchPagePathURL = web::test::HttpServer::MakeUrl( 784 GURL frenchPagePathURL = web::test::HttpServer::MakeUrl(
787 base::StringPrintf("http://%s", kFrenchPagePath)); 785 base::StringPrintf("http://%s", kFrenchPagePath));
788 [[EarlGrey 786 [ChromeEarlGrey waitForWebViewContainingText:"link"];
789 selectElementWithMatcher:chrome_test_util::WebViewContainingText("link")]
790 assertWithMatcher:grey_nil()];
791 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 787 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
792 frenchPagePathURL.GetContent())] 788 frenchPagePathURL.GetContent())]
793 assertWithMatcher:grey_notNil()]; 789 assertWithMatcher:grey_notNil()];
794 790
795 // Check that the auto-translation happened. 791 // Check that the auto-translation happened.
796 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 792 [ChromeEarlGrey waitForWebViewContainingText:"Translated"];
797 "Translated")]
798 assertWithMatcher:grey_notNil()];
799 } 793 }
800 794
801 #pragma mark - Utility methods 795 #pragma mark - Utility methods
802 796
803 // Waits until a language has been detected and checks the language details. 797 // Waits until a language has been detected and checks the language details.
804 - (void)assertLanguageDetails: 798 - (void)assertLanguageDetails:
805 (const LanguageDetectionController::DetectionDetails&)expectedDetails { 799 (const LanguageDetectionController::DetectionDetails&)expectedDetails {
806 GREYAssert(testing::WaitUntilConditionOrTimeout( 800 GREYAssert(testing::WaitUntilConditionOrTimeout(
807 2.0, 801 2.0,
808 ^{ 802 ^{
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 [[EarlGrey 846 [[EarlGrey
853 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( 847 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
854 IDS_TRANSLATE_INFOBAR_REVERT)] 848 IDS_TRANSLATE_INFOBAR_REVERT)]
855 assertWithMatcher:grey_notNil()]; 849 assertWithMatcher:grey_notNil()];
856 [[EarlGrey 850 [[EarlGrey
857 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( 851 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
858 IDS_CLOSE)] assertWithMatcher:grey_notNil()]; 852 IDS_CLOSE)] assertWithMatcher:grey_notNil()];
859 } 853 }
860 854
861 @end 855 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/metrics/tab_usage_recorder_egtest.mm ('k') | ios/chrome/browser/ui/browser_view_controller_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698