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

Unified Diff: ios/chrome/browser/ui/history/history_ui_egtest.mm

Issue 2598763002: [ios] Open links in history status message in new tab and add test (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/history/history_collection_view_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/history/history_ui_egtest.mm
diff --git a/ios/chrome/browser/ui/history/history_ui_egtest.mm b/ios/chrome/browser/ui/history/history_ui_egtest.mm
index 79819ea98e3e6ff88787978ccbf385d2b588d0b4..8ab1335438b0f2a7571597c7ca75bfc02f33c0ed 100644
--- a/ios/chrome/browser/ui/history/history_ui_egtest.mm
+++ b/ios/chrome/browser/ui/history/history_ui_egtest.mm
@@ -11,8 +11,15 @@
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
+#include "ios/chrome/browser/chrome_url_constants.h"
+#import "ios/chrome/browser/ui/history/history_entries_status_item.h"
#import "ios/chrome/browser/ui/history/history_entry_item.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_controller.h"
+#import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h"
+#import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h"
+#import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h"
+#import "ios/chrome/browser/ui/util/transparent_link_button.h"
+#include "ios/chrome/common/string_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/accessibility_util.h"
@@ -21,6 +28,9 @@
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
+#import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
+#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
+#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h"
#import "ios/testing/wait_util.h"
#import "ios/web/public/test/http_server.h"
#import "ios/web/public/test/http_server_util.h"
@@ -107,10 +117,48 @@ id<GREYMatcher> clearBrowsingDataButton() {
return buttonWithAccessibilityLabelId(IDS_IOS_CLEAR_BUTTON);
}
+void SignIn() {
baxley 2016/12/22 17:58:37 Could you add a comment? What do you think about
Jackie Quinn 2016/12/22 20:09:13 Works for me. Done.
+ // Set up a fake identity.
+ ChromeIdentity* identity =
+ [FakeChromeIdentity identityWithEmail:@"foo@gmail.com"
+ gaiaID:@"fooID"
+ name:@"Fake Foo"];
+ ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
+ identity);
+
+ const CGFloat scroll_displacement = 50.0;
baxley 2016/12/22 17:58:37 Is reliable on phones and iPads? Sergio fixed som
Jackie Quinn 2016/12/22 20:09:13 Oh yeah that seems to be a better solution! Update
+ [ChromeEarlGreyUI openToolsMenu];
+ [[[EarlGrey
+ selectElementWithMatcher:grey_accessibilityID(kToolsMenuSettingsId)]
+ usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
+ scroll_displacement)
+ onElementWithMatcher:grey_accessibilityID(kToolsMenuTableViewId)]
+ performAction:grey_tap()];
+
+ [[EarlGrey
+ selectElementWithMatcher:grey_accessibilityID(kSettingsSignInCellId)]
+ performAction:grey_tap()];
+ [[EarlGrey
+ selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabel(
+ identity.userEmail)]
+ performAction:grey_tap()];
+ [[EarlGrey selectElementWithMatcher:
+ chrome_test_util::buttonWithAccessibilityLabelId(
+ IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SIGNIN_BUTTON)]
+ performAction:grey_tap()];
+ [[EarlGrey selectElementWithMatcher:
+ chrome_test_util::buttonWithAccessibilityLabelId(
+ IDS_IOS_ACCOUNT_CONSISTENCY_CONFIRMATION_OK_BUTTON)]
+ performAction:grey_tap()];
+ [[EarlGrey
+ selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabelId(
+ IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)]
+ performAction:grey_tap()];
+}
} // namespace
// History UI tests.
-@interface HistoryUITestCase : ChromeTestCase {
+@interface AAAHistoryUITestCase : ChromeTestCase {
baxley 2016/12/22 17:58:37 What you think your special and can make your test
Jackie Quinn 2016/12/22 20:09:13 Isn't history our most important feature? Done.
baxley 2016/12/22 22:35:32 By the way, you should have totally called me out
Jackie Quinn 2016/12/22 22:45:14 Dang, missed opportunity 🙃
GURL _URL1;
GURL _URL2;
GURL _URL3;
@@ -127,7 +175,7 @@ id<GREYMatcher> clearBrowsingDataButton() {
@end
-@implementation HistoryUITestCase
+@implementation AAAHistoryUITestCase
// Set up called once for the class.
+ (void)setUp {
@@ -198,6 +246,52 @@ id<GREYMatcher> clearBrowsingDataButton() {
assertWithMatcher:grey_notNil()];
}
+// Test that history displays a message about entries only if the user is logged
+// in, and that tapping on the link in the message opens a new tab with the sync
+// help page.
+- (void)testHistoryEntriesStatusCell {
+ [self loadTestURLs];
+ [self openHistoryPanel];
+ // Assert that no message is shown when the user is not signed in.
+ GREYElementMatcherBlock* emptyEntriesItemMatcher =
+ [GREYElementMatcherBlock matcherWithMatchesBlock:^BOOL(id element) {
+ HistoryEntriesStatusCell* cell = (HistoryEntriesStatusCell*)element;
baxley 2016/12/22 17:58:37 ObjCCast ?
Jackie Quinn 2016/12/22 20:09:13 Done.
+ return !cell.textLabel.text;
+ }
+ descriptionBlock:^void(id<GREYDescription> description) {
+ [description
+ appendText:@"HistoryEntriesStatusCell does not display text"];
+ }];
+ [[EarlGrey selectElementWithMatcher:grey_kindOfClass(
+ [HistoryEntriesStatusCell class])]
+ assertWithMatcher:emptyEntriesItemMatcher];
baxley 2016/12/22 17:58:37 Do we need to know about the class type? we can't
Jackie Quinn 2016/12/22 20:09:13 Well, I could wait for the text I look for below t
+ [[EarlGrey selectElementWithMatcher:navigationDoneButton()]
+ performAction:grey_tap()];
+
+ // Sign in and assert that the page indicates what type of history entries
+ // are shown.
+ SignIn();
+ [self openHistoryPanel];
+ // Assert that message about entries is shown. The "history is showing local
+ // entries" message will be shown because sync is not set up for this test.
+ l10n_util::GetNSString(IDS_IOS_HISTORY_NO_SYNCED_RESULTS);
+ NSRange range;
+ NSString* text = ParseStringWithLink(
+ l10n_util::GetNSString(IDS_IOS_HISTORY_NO_SYNCED_RESULTS), &range);
+ [[EarlGrey selectElementWithMatcher:grey_text(text)]
+ assertWithMatcher:grey_notNil()];
+
+ // Tap on "Learn more" link and assert that new tab with the link is opened.
+ [[EarlGrey
+ selectElementWithMatcher:grey_kindOfClass([TransparentLinkButton class])]
baxley 2016/12/22 17:58:37 Is there anything we can use to match the link, ot
Jackie Quinn 2016/12/22 20:09:13 I don't think so... I could look for the first UI
+ performAction:grey_tap()];
+ chrome_test_util::AssertMainTabCount(2);
+ id<GREYMatcher> webViewMatcher = chrome_test_util::webViewContainingText(
+ "Sync and view tabs and history across devices");
+ [[EarlGrey selectElementWithMatcher:webViewMatcher]
+ assertWithMatcher:grey_notNil()];
baxley 2016/12/22 17:58:37 Are the signed in accounts removed at the end of t
Jackie Quinn 2016/12/22 20:09:13 Yes, disabling mock auth is run at the end of all
+}
+
// Tests that searching history displays only entries matching the search term.
- (void)testSearchHistory {
[self loadTestURLs];
« no previous file with comments | « ios/chrome/browser/ui/history/history_collection_view_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698