| 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/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "components/strings/grit/components_strings.h" | 10 #include "components/strings/grit/components_strings.h" |
| 11 #include "components/version_info/version_info.h" | 11 #include "components/version_info/version_info.h" |
| 12 #include "ios/chrome/browser/chrome_url_constants.h" | 12 #include "ios/chrome/browser/chrome_url_constants.h" |
| 13 #include "ios/chrome/browser/experimental_flags.h" | 13 #include "ios/chrome/browser/experimental_flags.h" |
| 14 #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" | 14 #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" |
| 15 #include "ios/chrome/test/app/navigation_test_util.h" | 15 #include "ios/chrome/test/app/navigation_test_util.h" |
| 16 #include "ios/chrome/test/app/web_view_interaction_test_util.h" | 16 #include "ios/chrome/test/app/web_view_interaction_test_util.h" |
| 17 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 17 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 18 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 18 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 19 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 19 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 20 #import "ios/testing/wait_util.h" | 20 #import "ios/testing/wait_util.h" |
| 21 #import "ios/web/public/web_client.h" | 21 #import "ios/web/public/web_client.h" |
| 22 #include "ui/base/device_form_factor.h" | 22 #include "ui/base/device_form_factor.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "url/scheme_host_port.h" | 24 #include "url/scheme_host_port.h" |
| 25 | 25 |
| 26 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 27 #error "This file requires ARC support." |
| 28 #endif |
| 29 |
| 26 using chrome_test_util::BackButton; | 30 using chrome_test_util::BackButton; |
| 27 using chrome_test_util::ForwardButton; | 31 using chrome_test_util::ForwardButton; |
| 28 using chrome_test_util::StaticHtmlViewContainingText; | 32 using chrome_test_util::StaticHtmlViewContainingText; |
| 29 using chrome_test_util::TapWebViewElementWithId; | 33 using chrome_test_util::TapWebViewElementWithId; |
| 30 using chrome_test_util::WebViewContainingText; | 34 using chrome_test_util::WebViewContainingText; |
| 31 | 35 |
| 32 namespace { | 36 namespace { |
| 33 | 37 |
| 34 // Loads WebUI page with given |host|. | 38 // Loads WebUI page with given |host|. |
| 35 void LoadWebUIUrl(const std::string& host) { | 39 void LoadWebUIUrl(const std::string& host) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 }), | 58 }), |
| 55 @"Omnibox did not contain %@", base::SysUTF8ToNSString(text)); | 59 @"Omnibox did not contain %@", base::SysUTF8ToNSString(text)); |
| 56 return YES; | 60 return YES; |
| 57 }; | 61 }; |
| 58 | 62 |
| 59 DescribeToBlock describe = ^(id<GREYDescription> description) { | 63 DescribeToBlock describe = ^(id<GREYDescription> description) { |
| 60 [description appendText:@"omnibox text "]; | 64 [description appendText:@"omnibox text "]; |
| 61 [description appendText:base::SysUTF8ToNSString(text)]; | 65 [description appendText:base::SysUTF8ToNSString(text)]; |
| 62 }; | 66 }; |
| 63 | 67 |
| 64 return grey_allOf(chrome_test_util::Omnibox(), | 68 return grey_allOf( |
| 65 [[[GREYElementMatcherBlock alloc] | 69 chrome_test_util::Omnibox(), |
| 66 initWithMatchesBlock:matches | 70 [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches |
| 67 descriptionBlock:describe] autorelease], | 71 descriptionBlock:describe], |
| 68 nil); | 72 nil); |
| 69 } | 73 } |
| 70 | 74 |
| 71 } // namespace | 75 } // namespace |
| 72 | 76 |
| 73 // Test case for chrome://* WebUI pages. | 77 // Test case for chrome://* WebUI pages. |
| 74 @interface WebUITestCase : ChromeTestCase | 78 @interface WebUITestCase : ChromeTestCase |
| 75 @end | 79 @end |
| 76 | 80 |
| 77 @implementation WebUITestCase | 81 @implementation WebUITestCase |
| 78 | 82 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 [[EarlGrey selectElementWithMatcher:WaitForOmniboxText(kChromeInvalidURL)] | 213 [[EarlGrey selectElementWithMatcher:WaitForOmniboxText(kChromeInvalidURL)] |
| 210 assertWithMatcher:grey_sufficientlyVisible()]; | 214 assertWithMatcher:grey_sufficientlyVisible()]; |
| 211 NSString* kError = | 215 NSString* kError = |
| 212 l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE); | 216 l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE); |
| 213 id<GREYMatcher> messageMatcher = [GREYMatchers matcherForText:kError]; | 217 id<GREYMatcher> messageMatcher = [GREYMatchers matcherForText:kError]; |
| 214 [[EarlGrey selectElementWithMatcher:messageMatcher] | 218 [[EarlGrey selectElementWithMatcher:messageMatcher] |
| 215 assertWithMatcher:grey_notNil()]; | 219 assertWithMatcher:grey_notNil()]; |
| 216 } | 220 } |
| 217 | 221 |
| 218 @end | 222 @end |
| OLD | NEW |