| OLD | NEW |
| 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 | 551 |
| 552 // Open some webpage. | 552 // Open some webpage. |
| 553 [ChromeEarlGrey loadURL:URL]; | 553 [ChromeEarlGrey loadURL:URL]; |
| 554 // Check that no language has been detected. | 554 // Check that no language has been detected. |
| 555 GREYAssert(_language_detection_details.get() == nullptr, | 555 GREYAssert(_language_detection_details.get() == nullptr, |
| 556 @"A language has been detected"); | 556 @"A language has been detected"); |
| 557 } | 557 } |
| 558 | 558 |
| 559 // Tests that the language detection infobar is displayed. | 559 // Tests that the language detection infobar is displayed. |
| 560 - (void)testLanguageDetectionInfobar { | 560 - (void)testLanguageDetectionInfobar { |
| 561 // TODO(crbug.com/709131): Evaluate and re-enable this test if necessary. | |
| 562 #if !TARGET_IPHONE_SIMULATOR | |
| 563 EARL_GREY_TEST_DISABLED(@"Test disabled on device."); | |
| 564 #endif | |
| 565 | |
| 566 // The translate machinery will not auto-fire without API keys, unless that | 561 // The translate machinery will not auto-fire without API keys, unless that |
| 567 // behavior is overridden for testing. | 562 // behavior is overridden for testing. |
| 568 translate::TranslateManager::SetIgnoreMissingKeyForTesting(true); | 563 translate::TranslateManager::SetIgnoreMissingKeyForTesting(true); |
| 569 | 564 |
| 570 // Reset translate prefs to default. | 565 // Reset translate prefs to default. |
| 571 std::unique_ptr<translate::TranslatePrefs> translatePrefs( | 566 std::unique_ptr<translate::TranslatePrefs> translatePrefs( |
| 572 ChromeIOSTranslateClient::CreateTranslatePrefs( | 567 ChromeIOSTranslateClient::CreateTranslatePrefs( |
| 573 chrome_test_util::GetOriginalBrowserState()->GetPrefs())); | 568 chrome_test_util::GetOriginalBrowserState()->GetPrefs())); |
| 574 translatePrefs->ResetToDefaults(); | 569 translatePrefs->ResetToDefaults(); |
| 575 | 570 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 // Check that the infobar does not contain the "Always Translate" switch. | 705 // Check that the infobar does not contain the "Always Translate" switch. |
| 711 NSString* switchLabel = GetTranslateInfobarSwitchLabel("Spanish"); | 706 NSString* switchLabel = GetTranslateInfobarSwitchLabel("Spanish"); |
| 712 [[EarlGrey | 707 [[EarlGrey |
| 713 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabel( | 708 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabel( |
| 714 switchLabel)] assertWithMatcher:grey_nil()]; | 709 switchLabel)] assertWithMatcher:grey_nil()]; |
| 715 } | 710 } |
| 716 | 711 |
| 717 // Tests that translation occurs automatically on second navigation to an | 712 // Tests that translation occurs automatically on second navigation to an |
| 718 // already translated page. | 713 // already translated page. |
| 719 - (void)testAutoTranslate { | 714 - (void)testAutoTranslate { |
| 720 // TODO(crbug.com/709131): Evaluate and re-enable this test if necessary. | |
| 721 #if !TARGET_IPHONE_SIMULATOR | |
| 722 EARL_GREY_TEST_DISABLED(@"Test disabled on device."); | |
| 723 #endif | |
| 724 | |
| 725 // The translate machinery will not auto-fire without API keys, unless that | 715 // The translate machinery will not auto-fire without API keys, unless that |
| 726 // behavior is overridden for testing. | 716 // behavior is overridden for testing. |
| 727 translate::TranslateManager::SetIgnoreMissingKeyForTesting(true); | 717 translate::TranslateManager::SetIgnoreMissingKeyForTesting(true); |
| 728 | 718 |
| 729 std::unique_ptr<web::DataResponseProvider> provider(new TestResponseProvider); | 719 std::unique_ptr<web::DataResponseProvider> provider(new TestResponseProvider); |
| 730 web::test::SetUpHttpServer(std::move(provider)); | 720 web::test::SetUpHttpServer(std::move(provider)); |
| 731 | 721 |
| 732 // Reset translate prefs to default. | 722 // Reset translate prefs to default. |
| 733 std::unique_ptr<translate::TranslatePrefs> translatePrefs( | 723 std::unique_ptr<translate::TranslatePrefs> translatePrefs( |
| 734 ChromeIOSTranslateClient::CreateTranslatePrefs( | 724 ChromeIOSTranslateClient::CreateTranslatePrefs( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 [[EarlGrey | 836 [[EarlGrey |
| 847 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( | 837 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( |
| 848 IDS_TRANSLATE_INFOBAR_REVERT)] | 838 IDS_TRANSLATE_INFOBAR_REVERT)] |
| 849 assertWithMatcher:grey_notNil()]; | 839 assertWithMatcher:grey_notNil()]; |
| 850 [[EarlGrey | 840 [[EarlGrey |
| 851 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( | 841 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( |
| 852 IDS_CLOSE)] assertWithMatcher:grey_notNil()]; | 842 IDS_CLOSE)] assertWithMatcher:grey_notNil()]; |
| 853 } | 843 } |
| 854 | 844 |
| 855 @end | 845 @end |
| OLD | NEW |