| 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/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/sys_string_conversions.h" |
| 8 #include "components/strings/grit/components_strings.h" | 9 #include "components/strings/grit/components_strings.h" |
| 9 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" | 10 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" |
| 10 #import "ios/chrome/browser/ui/find_bar/find_bar_controller_ios.h" | 11 #import "ios/chrome/browser/ui/find_bar/find_bar_controller_ios.h" |
| 11 #import "ios/chrome/browser/ui/find_bar/find_bar_view.h" | 12 #import "ios/chrome/browser/ui/find_bar/find_bar_view.h" |
| 12 #include "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h" | 13 #include "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h" |
| 13 #import "ios/chrome/test/app/tab_test_util.h" | 14 #import "ios/chrome/test/app/tab_test_util.h" |
| 14 #import "ios/chrome/test/earl_grey/accessibility_util.h" | 15 #import "ios/chrome/test/earl_grey/accessibility_util.h" |
| 15 #import "ios/chrome/test/earl_grey/chrome_assertions.h" | 16 #import "ios/chrome/test/earl_grey/chrome_assertions.h" |
| 16 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 17 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 17 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 18 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 18 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 19 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 19 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 20 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 20 #import "ios/testing/wait_util.h" | 21 #import "ios/testing/wait_util.h" |
| 21 #import "ios/web/public/test/http_server.h" | 22 #import "ios/web/public/test/http_server.h" |
| 22 #import "ios/web/public/test/http_server_util.h" | 23 #import "ios/web/public/test/http_server_util.h" |
| 23 #include "ui/base/l10n/l10n_util_mac.h" | 24 #include "ui/base/l10n/l10n_util_mac.h" |
| 24 | 25 |
| 25 #if !defined(__has_feature) || !__has_feature(objc_arc) | 26 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 26 #error "This file requires ARC support." | 27 #error "This file requires ARC support." |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // Test web page content. | 32 // Test web page content. |
| 32 const std::string kFindInPageResponse = "Find in page. Find in page."; | 33 const std::string kFindInPageResponse = "Find in page. Find in page."; |
| 33 | 34 |
| 34 } // namespace | 35 } // namespace |
| 35 | 36 |
| 36 using chrome_test_util::WebViewContainingText; | |
| 37 | |
| 38 // Tests for Find in Page. | 37 // Tests for Find in Page. |
| 39 @interface FindInPageTestCase : ChromeTestCase | 38 @interface FindInPageTestCase : ChromeTestCase |
| 40 | 39 |
| 41 // URL for a test page with |kFindInPageResponse|. | 40 // URL for a test page with |kFindInPageResponse|. |
| 42 @property(nonatomic, assign) GURL testURL; | 41 @property(nonatomic, assign) GURL testURL; |
| 43 | 42 |
| 44 // Opens Find in Page. | 43 // Opens Find in Page. |
| 45 - (void)openFindInPage; | 44 - (void)openFindInPage; |
| 46 // Closes Find in page. | 45 // Closes Find in page. |
| 47 - (void)closeFindInPage; | 46 - (void)closeFindInPage; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 [[EarlGrey selectElementWithMatcher:grey_accessibilityID( | 215 [[EarlGrey selectElementWithMatcher:grey_accessibilityID( |
| 217 kFindInPagePreviousButtonId)] | 216 kFindInPagePreviousButtonId)] |
| 218 performAction:grey_tap()]; | 217 performAction:grey_tap()]; |
| 219 } | 218 } |
| 220 | 219 |
| 221 - (void)navigateToTestPage { | 220 - (void)navigateToTestPage { |
| 222 // Navigate to a page with some text. | 221 // Navigate to a page with some text. |
| 223 [ChromeEarlGrey loadURL:self.testURL]; | 222 [ChromeEarlGrey loadURL:self.testURL]; |
| 224 | 223 |
| 225 // Verify web page finished loading. | 224 // Verify web page finished loading. |
| 226 [[EarlGrey | 225 [ChromeEarlGrey waitForWebViewContainingText:base::SysUTF8ToNSString( |
| 227 selectElementWithMatcher:WebViewContainingText(kFindInPageResponse)] | 226 kFindInPageResponse)]; |
| 228 assertWithMatcher:grey_notNil()]; | |
| 229 } | 227 } |
| 230 | 228 |
| 231 @end | 229 @end |
| OLD | NEW |