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

Unified Diff: ios/chrome/browser/metrics/tab_usage_recorder_unittest.mm

Issue 2820763002: Remove usage of Tab's |url| property from TabUsageRecorder. (Closed)
Patch Set: rebase Created 3 years, 7 months 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/metrics/tab_usage_recorder.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/metrics/tab_usage_recorder_unittest.mm
diff --git a/ios/chrome/browser/metrics/tab_usage_recorder_unittest.mm b/ios/chrome/browser/metrics/tab_usage_recorder_unittest.mm
index ca0817bb3b7d0c7201b6f0f7c9e7959367255ad4..31672db7ce4483cc2514fefd37b40d67a4a9db8a 100644
--- a/ios/chrome/browser/metrics/tab_usage_recorder_unittest.mm
+++ b/ios/chrome/browser/metrics/tab_usage_recorder_unittest.mm
@@ -4,6 +4,7 @@
#include <memory>
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram_samples.h"
#include "base/stl_util.h"
@@ -13,6 +14,8 @@
#import "ios/chrome/browser/metrics/tab_usage_recorder_delegate.h"
#import "ios/chrome/browser/tabs/tab.h"
#include "ios/testing/ocmock_complex_type_helper.h"
+#import "ios/web/public/test/fakes/test_navigation_manager.h"
+#import "ios/web/public/test/fakes/test_web_state.h"
#include "ios/web/public/test/test_web_thread.h"
#import "ios/web/web_state/ui/crw_web_controller.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -25,9 +28,16 @@
@interface TURTestTabMock : OCMockComplexTypeHelper {
GURL _url;
+ GURL _lastCommittedURL;
+ GURL _visibleURL;
+ web::TestWebState _webState;
}
@property(nonatomic, assign) const GURL& url;
+@property(nonatomic, assign) const GURL& lastCommittedURL;
+@property(nonatomic, assign) const GURL& visibleURL;
+@property(nonatomic, readonly) web::WebState* webState;
+
@end
@implementation TURTestTabMock
@@ -37,6 +47,25 @@ @implementation TURTestTabMock
- (void)setUrl:(const GURL&)url {
_url = url;
}
+- (const GURL&)lastCommittedURL {
+ return _lastCommittedURL;
+}
+- (void)setLastCommittedURL:(const GURL&)lastCommittedURL {
+ _lastCommittedURL = lastCommittedURL;
+}
+- (const GURL&)visibleURL {
+ return _visibleURL;
+}
+- (void)setVisibleURL:(const GURL&)visibleURL {
+ _visibleURL = visibleURL;
+}
+- (web::WebState*)webState {
+ if (!_webState.GetNavigationManager()) {
+ _webState.SetNavigationManager(
+ base::MakeUnique<web::TestNavigationManager>());
+ }
+ return &_webState;
+}
@end
// A mock TabUsageRecorderDelegate which allows the unit tests to control
@@ -106,6 +135,8 @@ id MockTab(bool inMemory) {
[[[tab_mock stub] andReturn:web_controller_mock] webController];
[[[tab_mock stub] andReturnBool:false] isPrerenderTab];
[tab_mock setUrl:webUrl_];
+ [tab_mock setLastCommittedURL:webUrl_];
+ [tab_mock setVisibleURL:webUrl_];
[[[web_controller_mock stub] andReturnBool:inMemory] isViewAlive];
[[web_controller_mock stub] removeObserver:OCMOCK_ANY];
return tab_mock;
@@ -173,7 +204,11 @@ id MockTab(bool inMemory) {
id tab_mock_a = MockTab(true);
id tab_mock_b = MockTab(false);
[tab_mock_a setUrl:nativeUrl_];
+ [tab_mock_a setLastCommittedURL:nativeUrl_];
+ [tab_mock_a setVisibleURL:nativeUrl_];
[tab_mock_b setUrl:nativeUrl_];
+ [tab_mock_b setLastCommittedURL:nativeUrl_];
+ [tab_mock_b setVisibleURL:nativeUrl_];
// Call reload an arbitrary number of times.
const int kNumReloads = 4;
« no previous file with comments | « ios/chrome/browser/metrics/tab_usage_recorder.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698