| 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 <EarlGrey/EarlGrey.h> | 5 #import <EarlGrey/EarlGrey.h> |
| 6 #import <UIKit/UIKit.h> | 6 #import <UIKit/UIKit.h> |
| 7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
| 8 | 8 |
| 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 24 matching lines...) Expand all Loading... |
| 35 #import "ios/web/public/test/http_server.h" | 35 #import "ios/web/public/test/http_server.h" |
| 36 #import "ios/web/public/test/http_server_util.h" | 36 #import "ios/web/public/test/http_server_util.h" |
| 37 #import "net/base/mac/url_conversions.h" | 37 #import "net/base/mac/url_conversions.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 39 | 39 |
| 40 #if !defined(__has_feature) || !__has_feature(objc_arc) | 40 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 41 #error "This file requires ARC support." | 41 #error "This file requires ARC support." |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 using chrome_test_util::ButtonWithAccessibilityLabelId; | 44 using chrome_test_util::ButtonWithAccessibilityLabelId; |
| 45 using chrome_test_util::OpenLinkInNewTabMenuItem; |
| 45 using chrome_test_util::WebViewContainingText; | 46 using chrome_test_util::WebViewContainingText; |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| 48 char kURL1[] = "http://firstURL"; | 49 char kURL1[] = "http://firstURL"; |
| 49 char kURL2[] = "http://secondURL"; | 50 char kURL2[] = "http://secondURL"; |
| 50 char kURL3[] = "http://thirdURL"; | 51 char kURL3[] = "http://thirdURL"; |
| 51 char kTitle1[] = "Page 1"; | 52 char kTitle1[] = "Page 1"; |
| 52 char kTitle2[] = "Page 2"; | 53 char kTitle2[] = "Page 2"; |
| 53 char kResponse1[] = "Test Page 1 content"; | 54 char kResponse1[] = "Test Page 1 content"; |
| 54 char kResponse2[] = "Test Page 2 content"; | 55 char kResponse2[] = "Test Page 2 content"; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 109 } |
| 109 // Matcher for the cancel button. | 110 // Matcher for the cancel button. |
| 110 id<GREYMatcher> CancelButton() { | 111 id<GREYMatcher> CancelButton() { |
| 111 return ButtonWithAccessibilityLabelId(IDS_HISTORY_CANCEL_EDITING_BUTTON); | 112 return ButtonWithAccessibilityLabelId(IDS_HISTORY_CANCEL_EDITING_BUTTON); |
| 112 } | 113 } |
| 113 // Matcher for the button to open the clear browsing data panel. | 114 // Matcher for the button to open the clear browsing data panel. |
| 114 id<GREYMatcher> OpenClearBrowsingDataButton() { | 115 id<GREYMatcher> OpenClearBrowsingDataButton() { |
| 115 return ButtonWithAccessibilityLabelId( | 116 return ButtonWithAccessibilityLabelId( |
| 116 IDS_HISTORY_OPEN_CLEAR_BROWSING_DATA_DIALOG); | 117 IDS_HISTORY_OPEN_CLEAR_BROWSING_DATA_DIALOG); |
| 117 } | 118 } |
| 118 // Matcher for the Open in New Tab option in the context menu. | |
| 119 id<GREYMatcher> OpenInNewTabButton() { | |
| 120 return ButtonWithAccessibilityLabelId(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB); | |
| 121 } | |
| 122 // Matcher for the Open in New Incognito Tab option in the context menu. | 119 // Matcher for the Open in New Incognito Tab option in the context menu. |
| 123 id<GREYMatcher> OpenInNewIncognitoTabButton() { | 120 id<GREYMatcher> OpenInNewIncognitoTabButton() { |
| 124 return ButtonWithAccessibilityLabelId( | 121 return ButtonWithAccessibilityLabelId( |
| 125 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB); | 122 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB); |
| 126 } | 123 } |
| 127 // Matcher for the Copy URL option in the context menu. | 124 // Matcher for the Copy URL option in the context menu. |
| 128 id<GREYMatcher> CopyUrlButton() { | 125 id<GREYMatcher> CopyUrlButton() { |
| 129 return ButtonWithAccessibilityLabelId(IDS_IOS_CONTENT_CONTEXT_COPY); | 126 return ButtonWithAccessibilityLabelId(IDS_IOS_CONTENT_CONTEXT_COPY); |
| 130 } | 127 } |
| 131 // Matcher for the clear cookies cell on the clear browsing data panel. | 128 // Matcher for the clear cookies cell on the clear browsing data panel. |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 - (void)testContextMenuOpenInNewTab { | 420 - (void)testContextMenuOpenInNewTab { |
| 424 [self loadTestURLs]; | 421 [self loadTestURLs]; |
| 425 [self openHistoryPanel]; | 422 [self openHistoryPanel]; |
| 426 | 423 |
| 427 // Long press on the history element. | 424 // Long press on the history element. |
| 428 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 425 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |
| 429 performAction:grey_longPress()]; | 426 performAction:grey_longPress()]; |
| 430 | 427 |
| 431 // Select "Open in New Tab" and confirm that new tab is opened with selected | 428 // Select "Open in New Tab" and confirm that new tab is opened with selected |
| 432 // URL. | 429 // URL. |
| 433 [[EarlGrey selectElementWithMatcher:OpenInNewTabButton()] | 430 [[EarlGrey selectElementWithMatcher:OpenLinkInNewTabMenuItem()] |
| 434 performAction:grey_tap()]; | 431 performAction:grey_tap()]; |
| 435 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( | 432 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( |
| 436 _URL1.GetContent())] | 433 _URL1.GetContent())] |
| 437 assertWithMatcher:grey_notNil()]; | 434 assertWithMatcher:grey_notNil()]; |
| 438 chrome_test_util::AssertMainTabCount(2); | 435 chrome_test_util::AssertMainTabCount(2); |
| 439 } | 436 } |
| 440 | 437 |
| 441 // Tests display and selection of 'Open in New Incognito Tab' in a context menu | 438 // Tests display and selection of 'Open in New Incognito Tab' in a context menu |
| 442 // on a history entry. | 439 // on a history entry. |
| 443 - (void)testContextMenuOpenInNewIncognitoTab { | 440 - (void)testContextMenuOpenInNewIncognitoTab { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 - (void)resetBrowsingDataPrefs { | 534 - (void)resetBrowsingDataPrefs { |
| 538 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); | 535 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); |
| 539 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); | 536 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); |
| 540 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); | 537 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); |
| 541 prefs->ClearPref(browsing_data::prefs::kDeleteCache); | 538 prefs->ClearPref(browsing_data::prefs::kDeleteCache); |
| 542 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); | 539 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); |
| 543 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); | 540 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); |
| 544 } | 541 } |
| 545 | 542 |
| 546 @end | 543 @end |
| OLD | NEW |