Commit 74d3e8ba authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

Remove extra logElementFetchDurationWithStartTime call.

Ensure that element fetch time is only logged once per fetch request.

Bug: 228355
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I997115965c1548ed02b58c29cca6896607b3761d
Reviewed-on: https://chromium-review.googlesource.com/942608
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540368}
parent cbe60510
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/app/histogram_test_util.h"
#import "ios/chrome/test/app/settings_test_util.h" #import "ios/chrome/test/app/settings_test_util.h"
#import "ios/chrome/test/app/tab_test_util.h" #import "ios/chrome/test/app/tab_test_util.h"
#import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
...@@ -280,6 +281,27 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) { ...@@ -280,6 +281,27 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) {
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
} }
// Tests that the element fetch duration is logged once with the
// kContextMenuElementPostMessage feature disabled.
- (void)testContextMenuElementFetchDurationMetric {
base::test::ScopedFeatureList scopedFeatureList;
scopedFeatureList.InitAndDisableFeature(
web::features::kContextMenuElementPostMessage);
chrome_test_util::HistogramTester histogramTester;
const GURL pageURL = self.testServer->GetURL(kLogoPagePath);
[ChromeEarlGrey loadURL:pageURL];
[ChromeEarlGrey waitForMainTabCount:1];
LongPressElement(kChromiumImageID);
TapOnContextMenuButton(OpenImageButton());
histogramTester.ExpectTotalCount("ContextMenu.DOMElementFetchDuration", 1,
^(NSString* error) {
GREYFail(error);
});
}
// Tests that selecting "Open Image" from the context menu properly opens the // Tests that selecting "Open Image" from the context menu properly opens the
// image in the current tab. (With the kContextMenuElementPostMessage feature // image in the current tab. (With the kContextMenuElementPostMessage feature
// enabled.) // enabled.)
...@@ -405,4 +427,25 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) { ...@@ -405,4 +427,25 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) {
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
} }
// Tests that the element fetch duration is logged once with the
// kContextMenuElementPostMessage feature enabled.
- (void)testContextMenuElementFetchDurationMetricPostMessage {
base::test::ScopedFeatureList scopedFeatureList;
scopedFeatureList.InitAndEnableFeature(
web::features::kContextMenuElementPostMessage);
chrome_test_util::HistogramTester histogramTester;
const GURL pageURL = self.testServer->GetURL(kLogoPagePath);
[ChromeEarlGrey loadURL:pageURL];
[ChromeEarlGrey waitForMainTabCount:1];
LongPressElement(kChromiumImageID);
TapOnContextMenuButton(OpenImageButton());
histogramTester.ExpectTotalCount("ContextMenu.DOMElementFetchDuration", 1,
^(NSString* error) {
GREYFail(error);
});
}
@end @end
...@@ -376,13 +376,10 @@ NSString* const kFindElementResultHandlerName = @"FindElementResultHandler"; ...@@ -376,13 +376,10 @@ NSString* const kFindElementResultHandlerName = @"FindElementResultHandler";
[self setDOMElementForLastTouch:nil]; [self setDOMElementForLastTouch:nil];
[self cancelContextMenuDisplay]; [self cancelContextMenuDisplay];
base::TimeTicks fetchStartTime = base::TimeTicks::Now();
__weak CRWContextMenuController* weakSelf = self; __weak CRWContextMenuController* weakSelf = self;
[self fetchDOMElementAtPoint:[touch locationInView:_webView] [self fetchDOMElementAtPoint:[touch locationInView:_webView]
completionHandler:^(NSDictionary* element) { completionHandler:^(NSDictionary* element) {
CRWContextMenuController* strongSelf = weakSelf; [weakSelf setDOMElementForLastTouch:element];
[strongSelf logElementFetchDurationWithStartTime:fetchStartTime];
[strongSelf setDOMElementForLastTouch:element];
}]; }];
return YES; return YES;
} }
......
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