Commit 67524868 authored by Olivier Robin's avatar Olivier Robin Committed by Commit Bot

[EG2] Convert RL test to EG2

Change-Id: I8e294d3c99382336ec425c67bb43a29cabdf89df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1889871
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712085}
parent bfe933e5
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "components/reading_list/core/reading_list_model.h" #include "components/reading_list/core/reading_list_model.h"
#include "ios/chrome/browser/application_context.h" #include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/reading_list/reading_list_distiller_page_factory.h" #include "ios/chrome/browser/reading_list/reading_list_distiller_page_factory.h"
#include "net/base/network_change_notifier.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
namespace { namespace {
...@@ -70,8 +71,7 @@ ReadingListDownloadService::ReadingListDownloadService( ...@@ -70,8 +71,7 @@ ReadingListDownloadService::ReadingListDownloadService(
distiller_page_factory) distiller_page_factory)
: reading_list_model_(reading_list_model), : reading_list_model_(reading_list_model),
chrome_profile_path_(chrome_profile_path), chrome_profile_path_(chrome_profile_path),
had_connection_( had_connection_(!net::NetworkChangeNotifier::IsOffline()),
!GetApplicationContext()->GetNetworkConnectionTracker()->IsOffline()),
distiller_page_factory_(std::move(distiller_page_factory)), distiller_page_factory_(std::move(distiller_page_factory)),
distiller_factory_(std::move(distiller_factory)), distiller_factory_(std::move(distiller_factory)),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
...@@ -208,7 +208,7 @@ void ReadingListDownloadService::DownloadEntry(const GURL& url) { ...@@ -208,7 +208,7 @@ void ReadingListDownloadService::DownloadEntry(const GURL& url) {
entry->DistilledState() == ReadingListEntry::PROCESSED || entry->IsRead()) entry->DistilledState() == ReadingListEntry::PROCESSED || entry->IsRead())
return; return;
if (GetApplicationContext()->GetNetworkConnectionTracker()->IsOffline()) { if (net::NetworkChangeNotifier::IsOffline()) {
// There is no connection, save it for download only if we did not exceed // There is no connection, save it for download only if we did not exceed
// the maximaxum number of tries. // the maximaxum number of tries.
if (entry->FailedDownloadCounter() < kNumberOfFailsBeforeWifiOnly) if (entry->FailedDownloadCounter() < kNumberOfFailsBeforeWifiOnly)
......
...@@ -69,6 +69,14 @@ source_set("reading_list") { ...@@ -69,6 +69,14 @@ source_set("reading_list") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
} }
source_set("reading_list_constants") {
sources = [
"reading_list_constants.h",
"reading_list_constants.mm",
]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("reading_list_ui") { source_set("reading_list_ui") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
...@@ -85,8 +93,6 @@ source_set("reading_list_ui") { ...@@ -85,8 +93,6 @@ source_set("reading_list_ui") {
"reading_list_table_view_controller.h", "reading_list_table_view_controller.h",
"reading_list_table_view_controller.mm", "reading_list_table_view_controller.mm",
"reading_list_toolbar_button_commands.h", "reading_list_toolbar_button_commands.h",
"reading_list_toolbar_button_identifiers.h",
"reading_list_toolbar_button_identifiers.mm",
"reading_list_toolbar_button_manager.h", "reading_list_toolbar_button_manager.h",
"reading_list_toolbar_button_manager.mm", "reading_list_toolbar_button_manager.mm",
"reading_list_ui_distillation_status.h", "reading_list_ui_distillation_status.h",
...@@ -94,6 +100,7 @@ source_set("reading_list_ui") { ...@@ -94,6 +100,7 @@ source_set("reading_list_ui") {
"text_badge_view.mm", "text_badge_view.mm",
] ]
deps = [ deps = [
":reading_list_constants",
"resources:reading_list_empty_state", "resources:reading_list_empty_state",
"resources:reading_list_empty_state_new", "resources:reading_list_empty_state_new",
"resources:reading_list_tools_icon", "resources:reading_list_tools_icon",
...@@ -158,6 +165,7 @@ source_set("unit_tests") { ...@@ -158,6 +165,7 @@ source_set("unit_tests") {
} }
source_set("eg_tests") { source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
sources = [ sources = [
...@@ -165,7 +173,9 @@ source_set("eg_tests") { ...@@ -165,7 +173,9 @@ source_set("eg_tests") {
] ]
deps = [ deps = [
":reading_list", ":reading_list",
":reading_list_constants",
":reading_list_ui", ":reading_list_ui",
":test_support",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/reading_list/core", "//components/reading_list/core",
...@@ -176,6 +186,7 @@ source_set("eg_tests") { ...@@ -176,6 +186,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:constants",
"//ios/chrome/browser/ui/table_view:feature_flags", "//ios/chrome/browser/ui/table_view:feature_flags",
"//ios/chrome/browser/ui/table_view:views", "//ios/chrome/browser/ui/table_view:views",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
...@@ -196,3 +207,88 @@ source_set("eg_tests") { ...@@ -196,3 +207,88 @@ source_set("eg_tests") {
"XCTest.framework", "XCTest.framework",
] ]
} }
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"reading_list_egtest.mm",
]
deps = [
":eg_test_support+eg2",
":reading_list_constants",
"//base",
"//base/test:test_support",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/table_view:constants",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ios/web/public/navigation:navigation",
"//net",
"//net:test_support",
]
libs = [ "UIKit.framework" ]
}
source_set("test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"reading_list_app_interface.h",
"reading_list_app_interface.mm",
]
deps = [
"//base/test:test_support",
"//base/test:test_support",
"//components/reading_list/core",
"//ios/chrome/browser/reading_list",
"//ios/chrome/test/app:test_support",
"//ios/testing:nserror_support",
"//ios/testing/earl_grey:earl_grey_support",
]
}
source_set("eg_app_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"reading_list_app_interface.h",
"reading_list_app_interface.mm",
]
deps = [
"//base/test:test_support",
"//components/reading_list/core",
"//ios/chrome/browser/reading_list",
"//ios/chrome/test/app:test_support",
"//ios/testing:nserror_support",
]
}
source_set("eg_test_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"reading_list_app_interface.h",
"reading_list_app_interface_stub.mm",
]
deps = [
"//base",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
]
}
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_APP_INTERFACE_H_
#define IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_APP_INTERFACE_H_
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#include "base/compiler_specific.h"
// ReadingListAppInterface contains the app-side
// implementation for helpers. These helpers are compiled into
// the app binary and can be called from either app or test code.
@interface ReadingListAppInterface : NSObject
// Whether offline pages are displayed in a native content (NO) or the main
// WKWebView (YES).
+ (BOOL)isOfflinePageWithoutNativeContentEnabled;
// Removes all entries in the ReadingListModel.
+ (NSError*)clearEntries WARN_UNUSED_RESULT;
// Adds an entry in the ReadingListModel.
+ (NSError*)addEntryWithURL:(NSURL*)url
title:(NSString*)title
read:(BOOL)read WARN_UNUSED_RESULT;
// The number of read entries in the ReadingListModel.
+ (NSInteger)readEntriesCount;
// The number of unread entries in the ReadingListModel.
+ (NSInteger)unreadEntriesCount;
// Checks whether the current webState has a StaticHTML view contaning |text|.
// This is only used when |isOfflinePageWithoutNativeContentEnabled| is NO.
+ (BOOL)staticHTMLViewContainingText:(NSString*)text;
// Simulate that the current connection is WiFI.
+ (void)forceConnectionToWifi;
// Sends a notification that connection is WiFi.
+ (void)notifyWifiConnection;
// Reset the connection type.
+ (void)resetConnectionType;
@end
#endif // IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_APP_INTERFACE_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/reading_list/reading_list_app_interface.h"
#include "base/memory/singleton.h"
#include "base/strings/sys_string_conversions.h"
#import "base/test/ios/wait_util.h"
#include "components/reading_list/core/reading_list_model.h"
#include "ios/chrome/browser/reading_list/features.h"
#include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/app/static_html_view_test_util.h"
#import "ios/chrome/test/app/tab_test_util.h"
#import "ios/testing/nserror_util.h"
#include "net/base/mac/url_conversions.h"
#include "net/base/network_change_notifier.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Returns the reading list model.
ReadingListModel* GetReadingListModel(NSError** error) {
ReadingListModel* model =
ReadingListModelFactory::GetInstance()->GetForBrowserState(
chrome_test_util::GetOriginalBrowserState());
if (!base::test::ios::WaitUntilConditionOrTimeout(2, ^{
return model->loaded();
})) {
*error = testing::NSErrorWithLocalizedDescription(
@"Reading List model did not load");
}
return model;
}
// Overrides the NetworkChangeNotifier to enable distillation even if the device
// does not have network.
class WifiNetworkChangeNotifier : public net::NetworkChangeNotifier {
public:
WifiNetworkChangeNotifier() : net::NetworkChangeNotifier() {}
ConnectionType GetCurrentConnectionType() const override {
return CONNECTION_WIFI;
}
private:
DISALLOW_COPY_AND_ASSIGN(WifiNetworkChangeNotifier);
};
// Overrides the NetworkChangeNotifier to enable distillation even if the device
// does not have network.
class ConnectionTypeOverrider {
public:
static ConnectionTypeOverrider* SharedInstance() {
return base::Singleton<ConnectionTypeOverrider>::get();
}
ConnectionTypeOverrider() {}
void OverrideConnectionType() {
network_change_disabler_.reset(
new net::NetworkChangeNotifier::DisableForTest());
wifi_network_.reset(new WifiNetworkChangeNotifier());
}
void ResetConnectionType() {
wifi_network_.reset();
network_change_disabler_.reset();
}
private:
std::unique_ptr<net::NetworkChangeNotifier::DisableForTest>
network_change_disabler_;
std::unique_ptr<WifiNetworkChangeNotifier> wifi_network_;
DISALLOW_COPY_AND_ASSIGN(ConnectionTypeOverrider);
};
} // namespace
@implementation ReadingListAppInterface
+ (NSError*)clearEntries {
NSError* error = nil;
ReadingListModel* model = GetReadingListModel(&error);
if (error) {
return error;
}
for (const GURL& url : model->Keys())
model->RemoveEntryByURL(url);
return nil;
}
+ (NSError*)addEntryWithURL:(NSURL*)url title:(NSString*)title read:(BOOL)read {
NSError* error = nil;
ReadingListModel* model = GetReadingListModel(&error);
if (error) {
return error;
}
model->AddEntry(net::GURLWithNSURL(url), base::SysNSStringToUTF8(title),
reading_list::ADDED_VIA_CURRENT_APP);
if (read) {
model->SetReadStatus(net::GURLWithNSURL(url), true);
}
return error;
}
+ (NSInteger)readEntriesCount {
NSError* error = nil;
ReadingListModel* model = GetReadingListModel(&error);
if (error) {
return -1;
}
return model->size() - model->unread_size();
}
+ (NSInteger)unreadEntriesCount {
NSError* error = nil;
ReadingListModel* model = GetReadingListModel(&error);
if (error) {
return -1;
}
return model->unread_size();
}
+ (BOOL)staticHTMLViewContainingText:(NSString*)text {
return chrome_test_util::StaticHtmlViewContainingText(
chrome_test_util::GetCurrentWebState(), base::SysNSStringToUTF8(text));
}
+ (BOOL)isOfflinePageWithoutNativeContentEnabled {
return reading_list::IsOfflinePageWithoutNativeContentEnabled();
}
+ (void)forceConnectionToWifi {
ConnectionTypeOverrider::SharedInstance()->OverrideConnectionType();
}
+ (void)notifyWifiConnection {
if (net::NetworkChangeNotifier::IsOffline()) {
net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests(
net::NetworkChangeNotifier::CONNECTION_WIFI);
}
}
+ (void)resetConnectionType {
ConnectionTypeOverrider::SharedInstance()->ResetConnectionType();
}
@end
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/reading_list/reading_list_app_interface.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#if defined(CHROME_EARL_GREY_2)
// TODO(crbug.com/1015113): The EG2 macro is breaking indexing for some reason
// without the trailing semicolon. For now, disable the extra semi warning
// so Xcode indexing works for the egtest.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat-extra-semi"
GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ReadingListAppInterface);
#pragma clang diagnostic pop
#endif // defined(CHROME_EARL_GREY_2)
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_TOOLBAR_BUTTON_IDENTIFIERS_H_ #ifndef IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_TOOLBAR_BUTTON_IDENTIFIERS_H_ #define IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_CONSTANTS_H_
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
// Accessibility identifier for reading list view.
extern NSString* const kReadingListViewID;
// Accessibility identifier for the badge icon.
extern NSString* const kTableViewURLCellFaviconBadgeViewID;
// Accessibility identifiers for reading list toolbar buttons. // Accessibility identifiers for reading list toolbar buttons.
extern NSString* const kReadingListToolbarEditButtonID; extern NSString* const kReadingListToolbarEditButtonID;
extern NSString* const kReadingListToolbarDeleteButtonID; extern NSString* const kReadingListToolbarDeleteButtonID;
...@@ -14,4 +20,4 @@ extern NSString* const kReadingListToolbarDeleteAllReadButtonID; ...@@ -14,4 +20,4 @@ extern NSString* const kReadingListToolbarDeleteAllReadButtonID;
extern NSString* const kReadingListToolbarCancelButtonID; extern NSString* const kReadingListToolbarCancelButtonID;
extern NSString* const kReadingListToolbarMarkButtonID; extern NSString* const kReadingListToolbarMarkButtonID;
#endif // IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_TOOLBAR_BUTTON_IDENTIFIERS_H_ #endif // IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_CONSTANTS_H_
...@@ -2,12 +2,17 @@ ...@@ -2,12 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_identifiers.h" #import "ios/chrome/browser/ui/reading_list/reading_list_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
NSString* const kReadingListViewID = @"ReadingListTableView";
NSString* const kTableViewURLCellFaviconBadgeViewID =
@"TableViewURLCellFaviconBadgeView";
NSString* const kReadingListToolbarEditButtonID = NSString* const kReadingListToolbarEditButtonID =
@"ReadingListToolbarEditButtonID"; @"ReadingListToolbarEditButtonID";
NSString* const kReadingListToolbarDeleteButtonID = NSString* const kReadingListToolbarDeleteButtonID =
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/list_model/list_item+Controller.h" #import "ios/chrome/browser/ui/list_model/list_item+Controller.h"
#import "ios/chrome/browser/ui/reading_list/empty_reading_list_message_util.h" #import "ios/chrome/browser/ui/reading_list/empty_reading_list_message_util.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_constants.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_data_sink.h" #import "ios/chrome/browser/ui/reading_list/reading_list_data_sink.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_data_source.h" #import "ios/chrome/browser/ui/reading_list/reading_list_data_source.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_list_item_updater.h" #import "ios/chrome/browser/ui/reading_list/reading_list_list_item_updater.h"
...@@ -189,7 +190,7 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts( ...@@ -189,7 +190,7 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
} }
+ (NSString*)accessibilityIdentifier { + (NSString*)accessibilityIdentifier {
return @"ReadingListTableView"; return kReadingListViewID;
} }
#pragma mark - UIViewController #pragma mark - UIViewController
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include "base/logging.h" #include "base/logging.h"
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_constants.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_commands.h" #import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_commands.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_identifiers.h"
#import "ios/chrome/common/colors/semantic_color_names.h" #import "ios/chrome/common/colors/semantic_color_names.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
......
...@@ -34,6 +34,8 @@ source_set("table_view") { ...@@ -34,6 +34,8 @@ source_set("table_view") {
source_set("constants") { source_set("constants") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"table_view_constants.h",
"table_view_constants.mm",
"table_view_navigation_controller_constants.h", "table_view_navigation_controller_constants.h",
"table_view_navigation_controller_constants.mm", "table_view_navigation_controller_constants.mm",
] ]
...@@ -78,6 +80,7 @@ source_set("views") { ...@@ -78,6 +80,7 @@ source_set("views") {
"table_view_loading_view.mm", "table_view_loading_view.mm",
] ]
deps = [ deps = [
":constants",
"//base", "//base",
"//ios/chrome/browser/ui/colors", "//ios/chrome/browser/ui/colors",
"//ios/chrome/browser/ui/material_components", "//ios/chrome/browser/ui/material_components",
......
...@@ -54,6 +54,7 @@ source_set("cells") { ...@@ -54,6 +54,7 @@ source_set("cells") {
"//ios/chrome/browser/ui/colors:colors", "//ios/chrome/browser/ui/colors:colors",
"//ios/chrome/browser/ui/elements", "//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/list_model", "//ios/chrome/browser/ui/list_model",
"//ios/chrome/browser/ui/reading_list:reading_list_constants",
"//ios/chrome/browser/ui/settings/cells:public", "//ios/chrome/browser/ui/settings/cells:public",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/table_view/cells/table_view_url_cell_favicon_badge_view.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_url_cell_favicon_badge_view.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
...@@ -21,7 +23,7 @@ ...@@ -21,7 +23,7 @@
#pragma mark - Public #pragma mark - Public
+ (NSString*)accessibilityIdentifier { + (NSString*)accessibilityIdentifier {
return @"TableViewURLCellFaviconBadgeView"; return kTableViewURLCellFaviconBadgeViewID;
} }
#pragma mark - UIImageView #pragma mark - UIImageView
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_TABLE_VIEW_TABLE_VIEW_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_TABLE_VIEW_TABLE_VIEW_CONSTANTS_H_
#import <Foundation/Foundation.h>
extern NSString* const kTableViewEmptyViewID;
#endif // IOS_CHROME_BROWSER_UI_TABLE_VIEW_TABLE_VIEW_CONSTANTS_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/table_view/table_view_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kTableViewEmptyViewID = @"TableViewEmptyView";
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/table_view/table_view_empty_view.h" #import "ios/chrome/browser/ui/table_view/table_view_empty_view.h"
#import "ios/chrome/browser/ui/table_view/table_view_constants.h"
#import "ios/chrome/common/colors/semantic_color_names.h" #import "ios/chrome/common/colors/semantic_color_names.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -84,7 +85,7 @@ NSAttributedString* GetAttributedMessage(NSString* message) { ...@@ -84,7 +85,7 @@ NSAttributedString* GetAttributedMessage(NSString* message) {
#pragma mark - Public #pragma mark - Public
+ (NSString*)accessibilityIdentifier { + (NSString*)accessibilityIdentifier {
return @"TableViewEmptyView"; return kTableViewEmptyViewID;
} }
- (void)setScrollViewContentInsets:(UIEdgeInsets)scrollViewContentInsets { - (void)setScrollViewContentInsets:(UIEdgeInsets)scrollViewContentInsets {
......
...@@ -272,6 +272,7 @@ source_set("test_support") { ...@@ -272,6 +272,7 @@ source_set("test_support") {
"//ios/chrome/browser/ui/static_content", "//ios/chrome/browser/ui/static_content",
"//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants", "//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants",
"//ios/chrome/browser/ui/tab_grid/grid:grid_ui_constants", "//ios/chrome/browser/ui/tab_grid/grid:grid_ui_constants",
"//ios/chrome/browser/ui/table_view:feature_flags",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/toolbar:test_support", "//ios/chrome/browser/ui/toolbar:test_support",
"//ios/chrome/browser/ui/toolbar:toolbar_ui", "//ios/chrome/browser/ui/toolbar:toolbar_ui",
...@@ -385,6 +386,7 @@ source_set("eg_app_support+eg2") { ...@@ -385,6 +386,7 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/ui/payments:payments_ui", "//ios/chrome/browser/ui/payments:payments_ui",
"//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/qr_scanner:eg_app_support+eg2", "//ios/chrome/browser/ui/qr_scanner:eg_app_support+eg2",
"//ios/chrome/browser/ui/reading_list:eg_app_support+eg2",
"//ios/chrome/browser/ui/recent_tabs:recent_tabs_ui_constants", "//ios/chrome/browser/ui/recent_tabs:recent_tabs_ui_constants",
"//ios/chrome/browser/ui/safe_mode", "//ios/chrome/browser/ui/safe_mode",
"//ios/chrome/browser/ui/safe_mode:eg_app_support+eg2", "//ios/chrome/browser/ui/safe_mode:eg_app_support+eg2",
...@@ -403,6 +405,7 @@ source_set("eg_app_support+eg2") { ...@@ -403,6 +405,7 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/ui/static_content", "//ios/chrome/browser/ui/static_content",
"//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants", "//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants",
"//ios/chrome/browser/ui/tab_grid/grid:grid_ui_constants", "//ios/chrome/browser/ui/tab_grid/grid:grid_ui_constants",
"//ios/chrome/browser/ui/table_view:feature_flags",
"//ios/chrome/browser/ui/toolbar:eg_app_support+eg2", "//ios/chrome/browser/ui/toolbar:eg_app_support+eg2",
"//ios/chrome/browser/ui/toolbar:toolbar_ui", "//ios/chrome/browser/ui/toolbar:toolbar_ui",
"//ios/chrome/browser/ui/toolbar/keyboard_assist", "//ios/chrome/browser/ui/toolbar/keyboard_assist",
......
...@@ -37,6 +37,12 @@ ...@@ -37,6 +37,12 @@
// web state. // web state.
+ (id<GREYAction>)tapWebElement:(ElementSelector*)selector; + (id<GREYAction>)tapWebElement:(ElementSelector*)selector;
// Action to scroll to top of a collection.
// On iOS 13 the settings menu appears as a card that can be dismissed with a
// downward swipe, for this reason we need to swipe up programatically to
// avoid dismissing the VC.
+ (id<GREYAction>)scrollToTop;
@end @end
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_ACTIONS_APP_INTERFACE_H_ #endif // IOS_CHROME_TEST_EARL_GREY_CHROME_ACTIONS_APP_INTERFACE_H_
...@@ -105,4 +105,25 @@ NSString* kChromeActionsErrorDomain = @"ChromeActionsError"; ...@@ -105,4 +105,25 @@ NSString* kChromeActionsErrorDomain = @"ChromeActionsError";
selector); selector);
} }
+ (id<GREYAction>)scrollToTop {
GREYPerformBlock scrollToTopBlock = ^BOOL(id element,
__strong NSError** error) {
grey_dispatch_sync_on_main_thread(^{
UIScrollView* view = base::mac::ObjCCast<UIScrollView>(element);
if (!view) {
*error = [NSError
errorWithDomain:kChromeActionsErrorDomain
code:0
userInfo:@{
NSLocalizedDescriptionKey : @"View is not a UIScrollView"
}];
}
view.contentOffset = CGPointZero;
});
return YES;
};
return [GREYActionBlock actionWithName:@"Scroll to top"
performBlock:scrollToTopBlock];
}
@end @end
...@@ -343,6 +343,9 @@ ...@@ -343,6 +343,9 @@
// with custom WebKit frameworks. // with custom WebKit frameworks.
+ (BOOL)isCustomWebKitLoadedIfRequested WARN_UNUSED_RESULT; + (BOOL)isCustomWebKitLoadedIfRequested WARN_UNUSED_RESULT;
// Returns YES if collections are presented in cards.
+ (BOOL)isCollectionsCardPresentationStyleEnabled WARN_UNUSED_RESULT;
#pragma mark - Popup Blocking #pragma mark - Popup Blocking
// Gets the current value of the popup content setting preference for the // Gets the current value of the popup content setting preference for the
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h" #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.h"
#import "ios/chrome/browser/ntp/features.h" #import "ios/chrome/browser/ntp/features.h"
#import "ios/chrome/browser/ui/settings/autofill/features.h" #import "ios/chrome/browser/ui/settings/autofill/features.h"
#import "ios/chrome/browser/ui/table_view/feature_flags.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/named_guide.h" #import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/web/tab_id_tab_helper.h" #import "ios/chrome/browser/web/tab_id_tab_helper.h"
...@@ -587,6 +588,10 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC; ...@@ -587,6 +588,10 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
return IsCustomWebKitLoadedIfRequested(); return IsCustomWebKitLoadedIfRequested();
} }
+ (BOOL)isCollectionsCardPresentationStyleEnabled {
return IsCollectionsCardPresentationStyleEnabled();
}
#pragma mark - ScopedBlockPopupsPref #pragma mark - ScopedBlockPopupsPref
+ (ContentSetting)popupPrefValue { + (ContentSetting)popupPrefValue {
......
...@@ -288,6 +288,9 @@ id<GREYMatcher> PaymentRequestPickerRow(); ...@@ -288,6 +288,9 @@ id<GREYMatcher> PaymentRequestPickerRow();
// Returns matcher for the payment request search bar. // Returns matcher for the payment request search bar.
id<GREYMatcher> PaymentRequestPickerSearchBar(); id<GREYMatcher> PaymentRequestPickerSearchBar();
// Returns matcher for the reading list on the Tools menu.
id<GREYMatcher> ReadingListMenuButton();
// Returns matcher for the bookmarks button on the Tools menu. // Returns matcher for the bookmarks button on the Tools menu.
id<GREYMatcher> BookmarksMenuButton(); id<GREYMatcher> BookmarksMenuButton();
......
...@@ -363,6 +363,10 @@ id<GREYMatcher> PaymentRequestPickerSearchBar() { ...@@ -363,6 +363,10 @@ id<GREYMatcher> PaymentRequestPickerSearchBar() {
return [ChromeMatchersAppInterface paymentRequestPickerSearchBar]; return [ChromeMatchersAppInterface paymentRequestPickerSearchBar];
} }
id<GREYMatcher> ReadingListMenuButton() {
return [ChromeMatchersAppInterface readingListMenuButton];
}
id<GREYMatcher> BookmarksMenuButton() { id<GREYMatcher> BookmarksMenuButton() {
return [ChromeMatchersAppInterface bookmarksMenuButton]; return [ChromeMatchersAppInterface bookmarksMenuButton];
} }
......
...@@ -293,6 +293,9 @@ ...@@ -293,6 +293,9 @@
// Returns matcher for the payment request search bar. // Returns matcher for the payment request search bar.
+ (id<GREYMatcher>)paymentRequestPickerSearchBar; + (id<GREYMatcher>)paymentRequestPickerSearchBar;
// Returns matcher for the reading list button on the Tools menu.
+ (id<GREYMatcher>)readingListMenuButton;
// Returns matcher for the bookmarks button on the Tools menu. // Returns matcher for the bookmarks button on the Tools menu.
+ (id<GREYMatcher>)bookmarksMenuButton; + (id<GREYMatcher>)bookmarksMenuButton;
......
...@@ -620,6 +620,10 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id, ...@@ -620,6 +620,10 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id,
return grey_accessibilityID(kPaymentRequestPickerSearchBarAccessibilityID); return grey_accessibilityID(kPaymentRequestPickerSearchBarAccessibilityID);
} }
+ (id<GREYMatcher>)readingListMenuButton {
return grey_accessibilityID(kToolsMenuReadingListId);
}
+ (id<GREYMatcher>)bookmarksMenuButton { + (id<GREYMatcher>)bookmarksMenuButton {
return grey_accessibilityID(kToolsMenuBookmarksId); return grey_accessibilityID(kToolsMenuBookmarksId);
} }
......
...@@ -80,6 +80,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") { ...@@ -80,6 +80,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") {
"//ios/chrome/browser/ui/page_info:eg2_tests", "//ios/chrome/browser/ui/page_info:eg2_tests",
"//ios/chrome/browser/ui/popup_menu:eg2_tests", "//ios/chrome/browser/ui/popup_menu:eg2_tests",
"//ios/chrome/browser/ui/qr_scanner:eg2_tests", "//ios/chrome/browser/ui/qr_scanner:eg2_tests",
"//ios/chrome/browser/ui/reading_list:eg2_tests",
"//ios/chrome/browser/ui/sad_tab:eg2_tests", "//ios/chrome/browser/ui/sad_tab:eg2_tests",
"//ios/chrome/browser/ui/safe_mode:eg2_tests", "//ios/chrome/browser/ui/safe_mode:eg2_tests",
"//ios/chrome/browser/ui/side_swipe:eg2_tests", "//ios/chrome/browser/ui/side_swipe:eg2_tests",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment