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

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

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: better formatting Created 3 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 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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 754
755 // Wait for all callbacks. 755 // Wait for all callbacks.
756 GREYAssert(testing::WaitUntilConditionOrTimeout( 756 GREYAssert(testing::WaitUntilConditionOrTimeout(
757 testing::kWaitForJSCompletionTimeout, 757 testing::kWaitForJSCompletionTimeout,
758 ^{ 758 ^{
759 return jsTranslateManager.get().translateStatusChecked; 759 return jsTranslateManager.get().translateStatusChecked;
760 }), 760 }),
761 @"Did not receive all translate status callbacks"); 761 @"Did not receive all translate status callbacks");
762 762
763 // Check that the translation happened. 763 // Check that the translation happened.
764 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 764 [ChromeEarlGrey waitForWebViewContainingText:@"Translated"];
765 "Translated")]
766 assertWithMatcher:grey_notNil()];
767 765
768 // Click on the link. 766 // Click on the link.
769 [ChromeEarlGrey tapWebViewElementWithID:@"link"]; 767 [ChromeEarlGrey tapWebViewElementWithID:@"link"];
770 GURL frenchPagePathURL = web::test::HttpServer::MakeUrl( 768 GURL frenchPagePathURL = web::test::HttpServer::MakeUrl(
771 base::StringPrintf("http://%s", kFrenchPagePath)); 769 base::StringPrintf("http://%s", kFrenchPagePath));
772 [[EarlGrey 770 [ChromeEarlGrey waitForWebViewContainingText:@"link"];
773 selectElementWithMatcher:chrome_test_util::WebViewContainingText("link")]
774 assertWithMatcher:grey_nil()];
775 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 771 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
776 frenchPagePathURL.GetContent())] 772 frenchPagePathURL.GetContent())]
777 assertWithMatcher:grey_notNil()]; 773 assertWithMatcher:grey_notNil()];
778 774
779 // Check that the auto-translation happened. 775 // Check that the auto-translation happened.
780 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 776 [ChromeEarlGrey waitForWebViewContainingText:@"Translated"];
781 "Translated")]
782 assertWithMatcher:grey_notNil()];
783 } 777 }
784 778
785 #pragma mark - Utility methods 779 #pragma mark - Utility methods
786 780
787 // Waits until a language has been detected and checks the language details. 781 // Waits until a language has been detected and checks the language details.
788 - (void)assertLanguageDetails: 782 - (void)assertLanguageDetails:
789 (const LanguageDetectionController::DetectionDetails&)expectedDetails { 783 (const LanguageDetectionController::DetectionDetails&)expectedDetails {
790 GREYAssert(testing::WaitUntilConditionOrTimeout( 784 GREYAssert(testing::WaitUntilConditionOrTimeout(
791 2.0, 785 2.0,
792 ^{ 786 ^{
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 [[EarlGrey 830 [[EarlGrey
837 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( 831 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
838 IDS_TRANSLATE_INFOBAR_REVERT)] 832 IDS_TRANSLATE_INFOBAR_REVERT)]
839 assertWithMatcher:grey_notNil()]; 833 assertWithMatcher:grey_notNil()];
840 [[EarlGrey 834 [[EarlGrey
841 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( 835 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
842 IDS_CLOSE)] assertWithMatcher:grey_notNil()]; 836 IDS_CLOSE)] assertWithMatcher:grey_notNil()];
843 } 837 }
844 838
845 @end 839 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698