Commit 98f067d3 authored by Olivier Robin's avatar Olivier Robin Committed by Commit Bot

[EG2] Convert tab_usage_recorder_egtests

Note: the tests that were disabled are still disabled.

Change-Id: Id39fe6a8342d379539b84c1d8a60f2e9ce053c19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928788
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722917}
parent fe970320
......@@ -144,6 +144,7 @@ source_set("metrics_internal") {
]
deps = [
":metrics",
":tab_usage_recorder_metrics",
"//base",
"//components/google/core/common",
"//ios/chrome/browser",
......@@ -160,6 +161,17 @@ source_set("metrics_internal") {
libs = [ "UIKit.framework" ]
}
source_set("tab_usage_recorder_metrics") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"tab_usage_recorder_metrics.h",
"tab_usage_recorder_metrics.mm",
]
deps = [
"//base",
]
}
source_set("unit_tests_internal") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
......@@ -194,6 +206,7 @@ source_set("eg_tests") {
]
deps = [
":metrics_internal",
":tab_usage_recorder_metrics",
":test_support",
"//base",
"//base/test:test_support",
......@@ -242,18 +255,23 @@ source_set("eg2_tests") {
]
testonly = true
sources = [
"tab_usage_recorder_egtest.mm",
"ukm_egtest.mm",
]
deps = [
":eg_test_support+eg2",
":tab_usage_recorder_metrics",
"//base/test:test_support",
"//components/strings:components_strings_grit",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/ui/authentication:eg_test_support+eg2",
"//ios/chrome/test:eg_test_support+eg2",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/public/provider/chrome/browser/signin:test_support",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ios/web/public/test:element_selector",
"//ios/web/public/test/http_server",
"//ui/base:base",
]
libs = [ "UIKit.framework" ]
......@@ -265,8 +283,6 @@ source_set("test_support") {
sources = [
"metrics_app_interface.h",
"metrics_app_interface.mm",
"tab_usage_recorder_test_util.h",
"tab_usage_recorder_test_util.mm",
]
deps = [
":metrics",
......@@ -277,6 +293,7 @@ source_set("test_support") {
"//ios/chrome/app:app_internal",
"//ios/chrome/app/strings",
"//ios/chrome/browser",
"//ios/chrome/browser/metrics:metrics_internal",
"//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui/main",
"//ios/chrome/browser/ui/popup_menu:constants",
......@@ -325,6 +342,7 @@ source_set("eg_app_support+eg2") {
"//components/ukm",
"//ios/chrome/browser",
"//ios/chrome/browser/metrics",
"//ios/chrome/browser/metrics:metrics_internal",
"//ios/chrome/test/app:test_support",
"//ios/testing:nserror_support",
"//services/metrics/public/cpp:metrics_cpp",
......@@ -344,6 +362,9 @@ source_set("eg_test_support+eg2") {
]
deps = [
"//base",
"//base/test:test_support",
"//ios/chrome/test:eg_test_support+eg2",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
]
......
......@@ -12,6 +12,7 @@
#include "base/containers/circular_deque.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "ios/chrome/browser/metrics/tab_usage_recorder_metrics.h"
#import "ios/chrome/browser/web_state_list/web_state_list_observer.h"
#include "ios/web/public/web_state_observer.h"
......@@ -22,104 +23,10 @@ namespace web {
class WebState;
}
// Histogram names (visible for testing only).
// The name of the histogram that records the state of the selected tab
// (i.e. the tab being switched to).
extern const char kSelectedTabHistogramName[];
// The name of the histogram that records the number of page loads before an
// evicted tab is selected.
extern const char kPageLoadsBeforeEvictedTabSelected[];
// The name of the histogram tracking the reload time for a previously-evicted
// tab.
extern const char kEvictedTabReloadTime[];
// The name of the histogram for whether or not the reload of a
// previously-evicted tab completed successfully.
extern const char kEvictedTabReloadSuccessRate[];
// The name of the histogram for whether or not the user switched tabs before an
// evicted tab completed reloading.
extern const char kDidUserWaitForEvictedTabReload[];
// The name of the histogram that records time intervals between restores of
// previously-evicted tabs. The first restore seen in a session will record the
// time since the session started.
extern const char kTimeBetweenRestores[];
// The name of the histogram that records time intervals between the last
// restore of a previously-evicted tab and the end of the session.
extern const char kTimeAfterLastRestore[];
// Name of histogram to record whether a memory warning had been recently
// received when a renderer termination occurred.
extern const char kRendererTerminationSawMemoryWarning[];
// Name of histogram to record the number of alive renderers when a renderer
// termination is received.
extern const char kRendererTerminationAliveRenderers[];
// Name of histogram to record the number of renderers that were alive shortly
// before a renderer termination. This metric is being recorded in case the OS
// kills renderers in batches.
extern const char kRendererTerminationRecentlyAliveRenderers[];
// Name of histogram for recording the state of the tab when the renderer is
// terminated.
extern const char kRendererTerminationStateHistogram[];
// The recently alive renderer count metric counts all renderers that were alive
// x seconds before a renderer termination. |kSecondsBeforeRendererTermination|
// specifies x.
extern const int kSecondsBeforeRendererTermination;
// Reports usage about the lifecycle of a single TabModel's tabs.
class TabUsageRecorder : public web::WebStateObserver,
public WebStateListObserver {
public:
enum TabStateWhenSelected {
IN_MEMORY = 0,
EVICTED,
EVICTED_DUE_TO_COLD_START,
PARTIALLY_EVICTED, // Currently, used only by Android.
EVICTED_DUE_TO_BACKGROUNDING, // Deprecated
EVICTED_DUE_TO_INCOGNITO,
RELOADED_DUE_TO_COLD_START_FG_TAB_ON_START, // Android.
RELOADED_DUE_TO_COLD_START_BG_TAB_ON_SWITCH, // Android.
LAZY_LOAD_FOR_OPEN_IN_NEW_TAB, // Android
STOPPED_DUE_TO_LOADING_WHEN_BACKGROUNDING, // Deprecated.
EVICTED_DUE_TO_LOADING_WHEN_BACKGROUNDING, // Deprecated.
EVICTED_DUE_TO_RENDERER_TERMINATION,
TAB_STATE_COUNT,
};
enum LoadDoneState {
LOAD_FAILURE,
LOAD_SUCCESS,
LOAD_DONE_STATE_COUNT,
};
enum EvictedTabUserBehavior {
USER_WAITED,
USER_DID_NOT_WAIT,
USER_LEFT_CHROME,
USER_BEHAVIOR_COUNT,
};
// Enum corresponding to UMA's TabForegroundState, for
// Tab.StateAtRendererTermination. Must be kept in sync with the UMA enum.
enum RendererTerminationTabState {
// These two values are for when the app is in the foreground.
FOREGROUND_TAB_FOREGROUND_APP = 0,
BACKGROUND_TAB_FOREGROUND_APP,
// These are for when the app is in the background or inactive.
FOREGROUND_TAB_BACKGROUND_APP,
BACKGROUND_TAB_BACKGROUND_APP,
TERMINATION_TAB_STATE_COUNT
};
// Initializes the TabUsageRecorder to watch |web_state_list|.
TabUsageRecorder(WebStateList* web_state_list,
PrerenderService* prerender_service);
......@@ -194,7 +101,8 @@ class TabUsageRecorder : public web::WebStateObserver,
// Returns the state of the given tab. Call only once per tab, as it removes
// the tab from |evicted_web_states_|.
TabStateWhenSelected ExtractWebStateState(web::WebState* web_state);
tab_usage_recorder::TabStateWhenSelected ExtractWebStateState(
web::WebState* web_state);
// Records various time metrics when a restore of an evicted tab begins.
void RecordRestoreStartTime();
......@@ -250,7 +158,8 @@ class TabUsageRecorder : public web::WebStateObserver,
web::WebState* evicted_web_state_ = nullptr;
// State of |evicted_web_state_| at the time it became the current tab.
TabStateWhenSelected evicted_web_state_state_ = IN_MEMORY;
tab_usage_recorder::TabStateWhenSelected evicted_web_state_state_ =
tab_usage_recorder::IN_MEMORY;
// Keep track of the tab last selected when this tab model was switched
// away from to another mode (e.g. to incognito).
......@@ -266,7 +175,8 @@ class TabUsageRecorder : public web::WebStateObserver,
base::TimeTicks evicted_web_state_reload_start_time_;
// Keep track of the tabs that have a known eviction cause.
std::map<web::WebState*, TabStateWhenSelected> evicted_web_states_;
std::map<web::WebState*, tab_usage_recorder::TabStateWhenSelected>
evicted_web_states_;
// The WebStateList containing all the monitored tabs.
WebStateList* web_state_list_; // weak
......
// 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_METRICS_TAB_USAGE_RECORDER_METRICS_H_
#define IOS_CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_METRICS_H_
namespace tab_usage_recorder {
// Histogram names (visible for testing only).
// The name of the histogram that records the state of the selected tab
// (i.e. the tab being switched to).
extern const char kSelectedTabHistogramName[];
// The name of the histogram that records the number of page loads before an
// evicted tab is selected.
extern const char kPageLoadsBeforeEvictedTabSelected[];
// The name of the histogram tracking the reload time for a previously-evicted
// tab.
extern const char kEvictedTabReloadTime[];
// The name of the histogram for whether or not the reload of a
// previously-evicted tab completed successfully.
extern const char kEvictedTabReloadSuccessRate[];
// The name of the histogram for whether or not the user switched tabs before an
// evicted tab completed reloading.
extern const char kDidUserWaitForEvictedTabReload[];
// The name of the histogram that records time intervals between restores of
// previously-evicted tabs. The first restore seen in a session will record the
// time since the session started.
extern const char kTimeBetweenRestores[];
// The name of the histogram that records time intervals between the last
// restore of a previously-evicted tab and the end of the session.
extern const char kTimeAfterLastRestore[];
// Name of histogram to record whether a memory warning had been recently
// received when a renderer termination occurred.
extern const char kRendererTerminationSawMemoryWarning[];
// Name of histogram to record the number of alive renderers when a renderer
// termination is received.
extern const char kRendererTerminationAliveRenderers[];
// Name of histogram to record the number of renderers that were alive shortly
// before a renderer termination. This metric is being recorded in case the OS
// kills renderers in batches.
extern const char kRendererTerminationRecentlyAliveRenderers[];
// Name of histogram for recording the state of the tab when the renderer is
// terminated.
extern const char kRendererTerminationStateHistogram[];
// The recently alive renderer count metric counts all renderers that were alive
// x seconds before a renderer termination. |kSecondsBeforeRendererTermination|
// specifies x.
extern const int kSecondsBeforeRendererTermination;
// enum for
// kSelectedTabHistogramName[] = "Tab.StatusWhenSwitchedBackToForeground"
// histogram.
enum TabStateWhenSelected {
IN_MEMORY = 0, // Memory resident
EVICTED = 1, // Evicted and reloaded
EVICTED_DUE_TO_COLD_START = 2, // Reloaded due to cold start
PARTIALLY_EVICTED =
3, // Partially evicted (Currently, used only by Android.)
EVICTED_DUE_TO_BACKGROUNDING =
4, // Reloaded due to backgrounding (Deprecated)
EVICTED_DUE_TO_INCOGNITO = 5, // Reloaded due to incognito
RELOADED_DUE_TO_COLD_START_FG_TAB_ON_START =
6, // Reloaded due to cold start (fg tab on start) (Android)
RELOADED_DUE_TO_COLD_START_BG_TAB_ON_SWITCH =
7, // Reloaded due to cold start (bg tab on switch) (Android)
LAZY_LOAD_FOR_OPEN_IN_NEW_TAB =
8, // Lazy load for 'Open in new tab' (Android)
STOPPED_DUE_TO_LOADING_WHEN_BACKGROUNDING =
9, // Stopped due to page loading when backgrounding (Deprecated)
EVICTED_DUE_TO_LOADING_WHEN_BACKGROUNDING =
10, // Evicted due to page loading when backgrounding (Deprecated)
EVICTED_DUE_TO_RENDERER_TERMINATION =
11, // Evicted due to OS terminating the renderer
TAB_STATE_COUNT = 12,
};
enum LoadDoneState {
LOAD_FAILURE,
LOAD_SUCCESS,
LOAD_DONE_STATE_COUNT,
};
enum EvictedTabUserBehavior {
USER_WAITED,
USER_DID_NOT_WAIT,
USER_LEFT_CHROME,
USER_BEHAVIOR_COUNT,
};
// Enum corresponding to UMA's TabForegroundState, for
// Tab.StateAtRendererTermination. Must be kept in sync with the UMA enum.
enum RendererTerminationTabState {
// These two values are for when the app is in the foreground.
FOREGROUND_TAB_FOREGROUND_APP = 0,
BACKGROUND_TAB_FOREGROUND_APP,
// These are for when the app is in the background or inactive.
FOREGROUND_TAB_BACKGROUND_APP,
BACKGROUND_TAB_BACKGROUND_APP,
TERMINATION_TAB_STATE_COUNT
};
} // namespace tab_usage_recorder
#endif // IOS_CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_METRICS_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.
#include "ios/chrome/browser/metrics/tab_usage_recorder_metrics.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace tab_usage_recorder {
// The histogram recording the state of the tab the user switches to.
const char kSelectedTabHistogramName[] =
"Tab.StatusWhenSwitchedBackToForeground";
// The histogram to record the number of page loads before an evicted tab is
// selected.
const char kPageLoadsBeforeEvictedTabSelected[] =
"Tab.PageLoadsSinceLastSwitchToEvictedTab";
// Records the time it takes for an evicted tab to reload.
const char kEvictedTabReloadTime[] = "Tab.RestoreTime";
// Records success vs failure of an evicted tab's reload.
const char kEvictedTabReloadSuccessRate[] = "Tab.RestoreResult";
// Records whether or not the user switched tabs before an evicted tab finished
// reloading.
const char kDidUserWaitForEvictedTabReload[] = "Tab.RestoreUserPersistence";
// The name of the histogram that records time intervals between tab restores.
const char kTimeBetweenRestores[] = "Tabs.TimeBetweenRestores";
// The name of the histogram that records time intervals since the last restore.
const char kTimeAfterLastRestore[] = "Tabs.TimeAfterLastRestore";
// Name of histogram to record whether a memory warning had been recently
// received when a renderer termination occurred.
const char kRendererTerminationSawMemoryWarning[] =
"Tab.RendererTermination.RecentlyReceivedMemoryWarning";
// Name of histogram to record the number of alive renderers when a renderer
// termination is received.
const char kRendererTerminationAliveRenderers[] =
"Tab.RendererTermination.AliveRenderersCount";
// Name of histogram to record the number of renderers that were alive shortly
// before a renderer termination. This metric is being recorded in case the OS
// kills renderers in batches.
const char kRendererTerminationRecentlyAliveRenderers[] =
"Tab.RendererTermination.RecentlyAliveRenderersCount";
// Name of histogram for recording the state of the tab when the renderer is
// terminated.
const char kRendererTerminationStateHistogram[] =
"Tab.StateAtRendererTermination";
// The recently alive renderer count metric counts all renderers that were alive
// x seconds before a renderer termination. |kSecondsBeforeRendererTermination|
// specifies x.
const int kSecondsBeforeRendererTermination = 2;
} // namespace tab_usage_recorder
// Copyright 2017 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_METRICS_TAB_USAGE_RECORDER_TEST_UTIL_H_
#define IOS_CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_TEST_UTIL_H_
#include "base/compiler_specific.h"
@class NSError;
namespace tab_usage_recorder_test_util {
// Opens a new incognito tab using the UI and evicts any main tab model tabs.
// Returns false on failure.
bool OpenNewIncognitoTabUsingUIAndEvictMainTabs() WARN_UNUSED_RESULT;
// Switches to normal mode using the tab switcher and selects the
// previously-selected normal tab. Assumes current mode is Incognito.
// Induces EG assert on failure.
void SwitchToNormalMode();
} // namespace tab_usage_recorder_test_util
#endif // IOS_CHROME_BROWSER_METRICS_TAB_USAGE_RECORDER_TEST_UTIL_H_
// Copyright 2017 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.
#include "ios/chrome/browser/metrics/tab_usage_recorder_test_util.h"
#import <EarlGrey/EarlGrey.h>
#import <Foundation/Foundation.h>
#import "base/ios/block_types.h"
#import "base/test/ios/wait_util.h"
#import "ios/chrome/app/main_controller.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/main/browser_interface_provider.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/browser/web_state_list/web_state_list.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
#import "ios/testing/nserror_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using base::test::ios::WaitUntilConditionOrTimeout;
namespace {
// The delay to wait for an element to appear before tapping on it.
const NSTimeInterval kWaitElementTimeout = 3;
} // namespace
namespace tab_usage_recorder_test_util {
bool OpenNewIncognitoTabUsingUIAndEvictMainTabs() {
int nb_incognito_tab = [ChromeEarlGrey incognitoTabCount];
[ChromeEarlGreyUI openToolsMenu];
id<GREYMatcher> new_incognito_tab_button_matcher =
grey_accessibilityID(kToolsMenuNewIncognitoTabId);
[[EarlGrey selectElementWithMatcher:new_incognito_tab_button_matcher]
performAction:grey_tap()];
[ChromeEarlGrey waitForIncognitoTabCount:(nb_incognito_tab + 1)];
bool success = WaitUntilConditionOrTimeout(kWaitElementTimeout, ^{
return [ChromeEarlGrey isIncognitoMode];
});
if (!success) {
return false;
}
[ChromeEarlGrey evictOtherTabModelTabs];
return true;
}
void SwitchToNormalMode() {
GREYAssertTrue([ChromeEarlGrey isIncognitoMode],
@"Switching to normal mode is only allowed from Incognito.");
// Enter the tab grid to switch modes.
[ChromeEarlGrey showTabSwitcher];
// Switch modes and exit the tab grid.
TabModel* model = chrome_test_util::GetMainController()
.interfaceProvider.mainInterface.tabModel;
const int tab_index = model.webStateList->active_index();
[[EarlGrey
selectElementWithMatcher:chrome_test_util::TabGridOpenTabsPanelButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridCellAtIndex(
tab_index)] performAction:grey_tap()];
BOOL success = NO;
// Turn off synchronization of GREYAssert to test the pending states.
{
ScopedSynchronizationDisabler disabler;
success = WaitUntilConditionOrTimeout(kWaitElementTimeout, ^{
return ![ChromeEarlGrey isIncognitoMode];
});
}
if (!success) {
// TODO(crbug.com/951600): Avoid asserting directly unless the test fails,
// due to timing issues.
GREYFail(@"Failed to switch to normal mode.");
}
}
} // namespace tab_usage_recorder_test_util
......@@ -46,6 +46,9 @@ void CloseCurrentTab();
// Closes tab with the given index in current mode (incognito or normal).
void CloseTabAtIndex(NSUInteger index);
// Returns the index of active tab in normal (non-incognito) mode.
NSUInteger GetIndexOfActiveNormalTab();
// Closes all tabs in the current mode (incognito or normal), and does not wait
// for the UI to complete. If current mode is Incognito, mode will be switched
// normal after closing all tabs.
......
......@@ -134,6 +134,12 @@ void CloseTabAtIndex(NSUInteger index) {
}
}
NSUInteger GetIndexOfActiveNormalTab() {
TabModel* model = chrome_test_util::GetMainController()
.interfaceProvider.mainInterface.tabModel;
return model.webStateList->active_index();
}
void CloseAllTabsInCurrentMode() {
[GetCurrentTabModel() closeAllTabs];
}
......
......@@ -129,6 +129,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// GREYAssert is induced.
- (void)waitForIncognitoTabCount:(NSUInteger)count;
// Loads |URL| as if it was opened from an external application.
- (void)openURLFromExternalApp:(const GURL&)URL;
#pragma mark - Settings Utilities (EG2)
// Sets value for content setting.
......@@ -257,6 +260,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// Returns the number of incognito tabs.
- (NSUInteger)incognitoTabCount WARN_UNUSED_RESULT;
// Returns the index of active tab in normal (non-incognito) mode.
- (NSUInteger)indexOfActiveNormalTab;
// Simulates a backgrounding and raises an EarlGrey exception if simulation not
// succeeded.
- (void)simulateTabsBackgrounding;
......
......@@ -15,6 +15,7 @@
#import "ios/testing/earl_grey/earl_grey_test.h"
#import "ios/testing/nserror_util.h"
#include "ios/web/public/test/element_selector.h"
#include "net/base/mac/url_conversions.h"
#if defined(CHROME_EARL_GREY_1)
#import <WebKit/WebKit.h>
......@@ -182,6 +183,11 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
}
}
- (void)openURLFromExternalApp:(const GURL&)URL {
NSString* spec = base::SysUTF8ToNSString(URL.spec());
[ChromeEarlGreyAppInterface openURLFromExternalApp:spec];
}
#pragma mark - Tab Utilities (EG2)
- (void)selectTabAtIndex:(NSUInteger)index {
......@@ -435,6 +441,10 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
EG_TEST_HELPER_ASSERT_TRUE(tabCountEqual, errorString);
}
- (NSUInteger)indexOfActiveNormalTab {
return [ChromeEarlGreyAppInterface indexOfActiveNormalTab];
}
- (void)waitForRestoreSessionToFinish {
GREYCondition* finishedRestoreSession = [GREYCondition
conditionWithName:kWaitForRestoreSessionToFinishError
......
......@@ -47,6 +47,9 @@
// or one of |view|'s ancestors. If no guide is found, returns nil.
+ (NamedGuide*)guideWithName:(NSString*)name view:(UIView*)view;
// Loads |URL| as if it was opened from an external application.
+ (void)openURLFromExternalApp:(NSString*)URL;
#pragma mark - Tab Utilities (EG2)
// Selects tab with given index in current mode (incognito or main
......@@ -135,6 +138,9 @@
// Returns a unique identifier for the next Tab.
+ (NSString*)nextTabID;
// Returns the index of active tab in normal mode.
+ (NSUInteger)indexOfActiveNormalTab;
#pragma mark - WebState Utilities (EG2)
// Attempts to tap the element with |element_id| within window.frames[0] of the
......
......@@ -42,6 +42,7 @@
#import "ios/web/public/ui/crw_web_view_proxy.h"
#import "ios/web/public/web_client.h"
#import "ios/web/public/web_state.h"
#include "net/base/mac/url_conversions.h"
#import "services/metrics/public/cpp/ukm_recorder.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -100,6 +101,11 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
return [NamedGuide guideWithName:name view:view];
}
+ (void)openURLFromExternalApp:(NSString*)URL {
chrome_test_util::OpenChromeFromExternalApp(
GURL(base::SysNSStringToUTF8(URL)));
}
#pragma mark - Tab Utilities (EG2)
+ (void)selectTabAtIndex:(NSUInteger)index {
......@@ -222,6 +228,10 @@ using chrome_test_util::BrowserCommandDispatcherForMainBVC;
return TabIdTabHelper::FromWebState(web_state)->tab_id();
}
+ (NSUInteger)indexOfActiveNormalTab {
return chrome_test_util::GetIndexOfActiveNormalTab();
}
#pragma mark - WebState Utilities (EG2)
+ (NSError*)tapWebStateElementInIFrameWithID:(NSString*)elementID {
......
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