Commit 2f18dc81 authored by Regan Hsu's avatar Regan Hsu Committed by Commit Bot

[CrOS Settings] Record User Action Navigation on route change.

This CL will not land until
https://chromium-review.googlesource.com/c/chromium/src/+/2051038
and
https://chromium-review.googlesource.com/c/chromium/src/+/2051164
lands.

Bug: 1049830
Change-Id: I064397122611884eb4e3ed22650c06dda1955191
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050097
Commit-Queue: Regan Hsu <hsuregan@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741193}
parent 1884f5b9
...@@ -216,9 +216,18 @@ Polymer({ ...@@ -216,9 +216,18 @@ Polymer({
settings.Router.getInstance().resetRouteForTesting(); settings.Router.getInstance().resetRouteForTesting();
}, },
/** @param {!settings.Route} route */ /**
currentRouteChanged(route) { * @param {!settings.Route} newRoute
if (route.depth <= 1) { * @param {!settings.Route} oldRoute
*/
currentRouteChanged(newRoute, oldRoute) {
if (oldRoute && newRoute != oldRoute) {
// Search triggers route changes and currentRouteChanged() is called
// in attached() state which is extraneous for this metric.
settings.recordNavigation();
}
if (newRoute.depth <= 1) {
// Main page uses scroll visibility to determine shadow. // Main page uses scroll visibility to determine shadow.
this.enableShadowBehavior(true); this.enableShadowBehavior(true);
} else { } else {
......
...@@ -22,14 +22,17 @@ var OSSettingsUIBrowserTest = class extends PolymerTest { ...@@ -22,14 +22,17 @@ var OSSettingsUIBrowserTest = class extends PolymerTest {
/** @override */ /** @override */
get extraLibraries() { get extraLibraries() {
return super.extraLibraries.concat( return super.extraLibraries.concat([
BROWSER_SETTINGS_PATH + '../test_util.js'); BROWSER_SETTINGS_PATH + '../test_util.js',
'fake_user_action_recorder.js',
]);
} }
}; };
TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => { TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => {
suite('os-settings-ui', () => { suite('os-settings-ui', () => {
let ui; let ui;
let userActionRecorder;
suiteSetup(() => { suiteSetup(() => {
testing.Test.disableAnimationsAndTransitions(); testing.Test.disableAnimationsAndTransitions();
...@@ -38,10 +41,16 @@ TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => { ...@@ -38,10 +41,16 @@ TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => {
}); });
setup(() => { setup(() => {
userActionRecorder = new settings.FakeUserActionRecorder();
settings.setUserActionRecorderForTesting(userActionRecorder);
ui.$.drawerTemplate.if = false; ui.$.drawerTemplate.if = false;
Polymer.dom.flush(); Polymer.dom.flush();
}); });
teardown(() => {
settings.setUserActionRecorderForTesting(null);
});
test('top container shadow always shows for sub-pages', () => { test('top container shadow always shows for sub-pages', () => {
const element = ui.$$('#cr-container-shadow-top'); const element = ui.$$('#cr-container-shadow-top');
assertTrue(!!element, 'Shadow container element always exists'); assertTrue(!!element, 'Shadow container element always exists');
...@@ -235,6 +244,14 @@ TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => { ...@@ -235,6 +244,14 @@ TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => {
assertEquals( assertEquals(
'', settings.Router.getInstance().getQueryParameters().toString()); '', settings.Router.getInstance().getQueryParameters().toString());
}); });
test('userActionRouteChange', function() {
assertEquals(userActionRecorder.navigationCount, 0);
settings.Router.getInstance().navigateTo(settings.routes.POWER);
assertEquals(userActionRecorder.navigationCount, 1);
settings.Router.getInstance().navigateTo(settings.routes.POWER);
assertEquals(userActionRecorder.navigationCount, 1);
});
}); });
mocha.run(); mocha.run();
......
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