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({
settings.Router.getInstance().resetRouteForTesting();
},
/** @param {!settings.Route} route */
currentRouteChanged(route) {
if (route.depth <= 1) {
/**
* @param {!settings.Route} newRoute
* @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.
this.enableShadowBehavior(true);
} else {
......
......@@ -22,14 +22,17 @@ var OSSettingsUIBrowserTest = class extends PolymerTest {
/** @override */
get extraLibraries() {
return super.extraLibraries.concat(
BROWSER_SETTINGS_PATH + '../test_util.js');
return super.extraLibraries.concat([
BROWSER_SETTINGS_PATH + '../test_util.js',
'fake_user_action_recorder.js',
]);
}
};
TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => {
suite('os-settings-ui', () => {
let ui;
let userActionRecorder;
suiteSetup(() => {
testing.Test.disableAnimationsAndTransitions();
......@@ -38,10 +41,16 @@ TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => {
});
setup(() => {
userActionRecorder = new settings.FakeUserActionRecorder();
settings.setUserActionRecorderForTesting(userActionRecorder);
ui.$.drawerTemplate.if = false;
Polymer.dom.flush();
});
teardown(() => {
settings.setUserActionRecorderForTesting(null);
});
test('top container shadow always shows for sub-pages', () => {
const element = ui.$$('#cr-container-shadow-top');
assertTrue(!!element, 'Shadow container element always exists');
......@@ -235,6 +244,14 @@ TEST_F('OSSettingsUIBrowserTest', 'AllJsTests', () => {
assertEquals(
'', 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();
......
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