Commit 10ae04f4 authored by James Cook's avatar James Cook Committed by Commit Bot

chromeos: Re-enable Android app parts of OSSettingsAppsPageTest

https://chromium-review.googlesource.com/c/chromium/src/+/1815957 merged
the Google Play Store settings into the top-level Apps section. This
removed the ANDROID_APPS route, so the existing tests can't provide
coverage.

This CL rewrites the tests of the Android apps sub-page so they
construct the sub-page directly, rather than trying to click to
navigate to it. This avoids the problem with the ANDROID_APPS route,
and may help with the flakiness that caused the tests to be disabled
in the first place.

Bug: 1004583, 1006662
Test: browser_tests
Change-Id: I9e22a1c4a90163b1c3093e5ec1648e62f7e4a61f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824020
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarJeevan Shikaram <jshikaram@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699597}
parent 45d3c7fe
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
on-click="onManageAndroidAppsTap_" external></cr-link-row> on-click="onManageAndroidAppsTap_" external></cr-link-row>
</template> </template>
<template is="dom-if" if="[[allowRemove_(prefs.arc.enabled.*)]]"> <!-- Use 'restamp' so tests can check if the row exists. -->
<template is="dom-if" if="[[allowRemove_(prefs.arc.enabled.*)]]" restamp>
<div id="remove" class="settings-box"> <div id="remove" class="settings-box">
<div id="androidRemoveLabel" class="start"> <div id="androidRemoveLabel" class="start">
$i18n{androidAppsRemove} $i18n{androidAppsRemove}
......
...@@ -36,10 +36,6 @@ suite('AndroidAppsPageTests', function() { ...@@ -36,10 +36,6 @@ suite('AndroidAppsPageTests', function() {
androidAppsPage.remove(); androidAppsPage.remove();
}); });
teardown(function() {
androidAppsPage.remove();
});
suite('Main Page', function() { suite('Main Page', function() {
setup(function() { setup(function() {
androidAppsPage.havePlayStoreApp = true; androidAppsPage.havePlayStoreApp = true;
......
...@@ -8,18 +8,10 @@ let appsPage = null; ...@@ -8,18 +8,10 @@ let appsPage = null;
/** @type {?TestAndroidAppsBrowserProxy} */ /** @type {?TestAndroidAppsBrowserProxy} */
let androidAppsBrowserProxy = null; let androidAppsBrowserProxy = null;
const setAndroidAppsState = function(playStoreEnabled, settingsAppAvailable) {
const appsInfo = {
playStoreEnabled: playStoreEnabled,
settingsAppAvailable: settingsAppAvailable,
};
appsPage.androidAppsInfo = appsInfo;
appsPage.showAndroidApps = true;
Polymer.dom.flush();
};
suite('AppsPageTests', function() { suite('AppsPageTests', function() {
setup(function() { setup(function() {
androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy();
settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy;
PolymerTest.clearBody(); PolymerTest.clearBody();
appsPage = document.createElement('os-settings-apps-page'); appsPage = document.createElement('os-settings-apps-page');
document.body.appendChild(appsPage); document.body.appendChild(appsPage);
...@@ -28,6 +20,7 @@ suite('AppsPageTests', function() { ...@@ -28,6 +20,7 @@ suite('AppsPageTests', function() {
teardown(function() { teardown(function() {
appsPage.remove(); appsPage.remove();
appsPage = null;
}); });
suite('Page Combinations', function() { suite('Page Combinations', function() {
...@@ -75,31 +68,20 @@ suite('AppsPageTests', function() { ...@@ -75,31 +68,20 @@ suite('AppsPageTests', function() {
assertTrue(AndroidAppsShown()); assertTrue(AndroidAppsShown());
}); });
}); });
});
// Changes to this suite should be reflected in android_apps_page_test.js
suite('AndroidAppsDetailPageTests', function() {
setup(function() {
androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy();
settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy;
PolymerTest.clearBody();
appsPage = document.createElement('os-settings-apps-page');
document.body.appendChild(appsPage);
testing.Test.disableAnimationsAndTransitions();
});
teardown(function() {
appsPage.remove();
});
suite('Main Page', function() { suite('Main Page', function() {
setup(function() { setup(function() {
appsPage.showAndroidApps = true;
appsPage.havePlayStoreApp = true; appsPage.havePlayStoreApp = true;
appsPage.prefs = {arc: {enabled: {value: false}}}; appsPage.prefs = {arc: {enabled: {value: false}}};
setAndroidAppsState(false, false); appsPage.androidAppsInfo = {
playStoreEnabled: false,
settingsAppAvailable: false,
};
Polymer.dom.flush();
}); });
test('Enable', function() { test('Clicking enable button enables ARC', function() {
const button = appsPage.$$('#enable'); const button = appsPage.$$('#enable');
assertTrue(!!button); assertTrue(!!button);
assertFalse(!!appsPage.$$('.subpage-arrow')); assertFalse(!!appsPage.$$('.subpage-arrow'));
...@@ -108,45 +90,40 @@ suite('AndroidAppsDetailPageTests', function() { ...@@ -108,45 +90,40 @@ suite('AndroidAppsDetailPageTests', function() {
Polymer.dom.flush(); Polymer.dom.flush();
assertTrue(appsPage.prefs.arc.enabled.value); assertTrue(appsPage.prefs.arc.enabled.value);
setAndroidAppsState(true, false); appsPage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: false,
};
Polymer.dom.flush();
assertTrue(!!appsPage.$$('.subpage-arrow')); assertTrue(!!appsPage.$$('.subpage-arrow'));
}); });
// TODO(crbug.com/1006662): Test that setting playStoreEnabled to false
// navigates back to the main apps section.
}); });
// TODO(crbug.com/1006662): Fix test suite. suite('Android apps subpage', function() {
suite.skip('SubPage', function() { let subpage = null;
let subpage;
function flushAsync() {
Polymer.dom.flush();
return new Promise(resolve => {
appsPage.async(resolve);
});
}
/**
* Returns a new promise that resolves after a window 'popstate' event.
* @return {!Promise}
*/
function whenPopState() {
return new Promise(function(resolve) {
window.addEventListener('popstate', function callback() {
window.removeEventListener('popstate', callback);
resolve();
});
});
}
setup(function() { setup(function() {
appsPage.havePlayStoreApp = true; androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy();
appsPage.prefs = {arc: {enabled: {value: true}}}; settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy;
setAndroidAppsState(true, false); PolymerTest.clearBody();
settings.navigateTo(settings.routes.ANDROID_APPS); subpage = document.createElement('settings-android-apps-subpage');
appsPage.$$('#android-apps').click(); document.body.appendChild(subpage);
return flushAsync().then(() => { testing.Test.disableAnimationsAndTransitions();
subpage = appsPage.$$('settings-android-apps-subpage');
assertTrue(!!subpage); subpage.prefs = {arc: {enabled: {value: true}}};
}); subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: false,
};
Polymer.dom.flush();
});
teardown(function() {
subpage.remove();
subpage = null;
}); });
test('Sanity', function() { test('Sanity', function() {
...@@ -156,14 +133,27 @@ suite('AndroidAppsDetailPageTests', function() { ...@@ -156,14 +133,27 @@ suite('AndroidAppsDetailPageTests', function() {
test('ManageAppsUpdate', function() { test('ManageAppsUpdate', function() {
assertTrue(!subpage.$$('#manageApps')); assertTrue(!subpage.$$('#manageApps'));
setAndroidAppsState(true, true); subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: true,
};
Polymer.dom.flush();
assertTrue(!!subpage.$$('#manageApps')); assertTrue(!!subpage.$$('#manageApps'));
setAndroidAppsState(true, false);
subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: false,
};
Polymer.dom.flush();
assertTrue(!subpage.$$('#manageApps')); assertTrue(!subpage.$$('#manageApps'));
}); });
test('ManageAppsOpenRequest', function() { test('ManageAppsOpenRequest', function() {
setAndroidAppsState(true, true); subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: true,
};
Polymer.dom.flush();
const button = subpage.$$('#manageApps'); const button = subpage.$$('#manageApps');
assertTrue(!!button); assertTrue(!!button);
const promise = const promise =
...@@ -187,23 +177,8 @@ suite('AndroidAppsDetailPageTests', function() { ...@@ -187,23 +177,8 @@ suite('AndroidAppsDetailPageTests', function() {
dialog.close(); dialog.close();
}); });
test('HideOnDisable', function() { test('ARC enabled by policy', function() {
assertEquals( subpage.prefs = {
settings.getCurrentRoute(), settings.routes.ANDROID_APPS_DETAILS);
setAndroidAppsState(false, false);
return whenPopState().then(function() {
assertEquals(settings.getCurrentRoute(), settings.routes.ANDROID_APPS);
});
});
});
// TODO(crbug.com/1006662): Fix test suite.
suite.skip('Enforced', function() {
let subpage;
setup(function() {
appsPage.havePlayStoreApp = true;
appsPage.prefs = {
arc: { arc: {
enabled: { enabled: {
value: true, value: true,
...@@ -211,34 +186,25 @@ suite('AndroidAppsDetailPageTests', function() { ...@@ -211,34 +186,25 @@ suite('AndroidAppsDetailPageTests', function() {
} }
} }
}; };
setAndroidAppsState(true, true); subpage.androidAppsInfo = {
assertTrue(!!settings.routes.ANDROID_APPS_DETAILS); playStoreEnabled: true,
appsPage.$$('#android-apps').click(); settingsAppAvailable: true,
};
Polymer.dom.flush(); Polymer.dom.flush();
subpage = appsPage.$$('settings-android-apps-subpage');
assertTrue(!!subpage);
});
test('Sanity', function(done) {
Polymer.dom.flush();
assertFalse(!!subpage.$$('#remove')); assertFalse(!!subpage.$$('#remove'));
assertTrue(!!subpage.$$('#manageApps')); assertTrue(!!subpage.$$('#manageApps'));
}); });
});
suite('NoPlayStore', function() {
setup(function() {
appsPage.havePlayStoreApp = false;
appsPage.prefs = {arc: {enabled: {value: true}}};
setAndroidAppsState(true, true);
});
test('Sanity', function() { test('Can open app settings without Play Store', function() {
assertTrue(!!appsPage.$$('#manageApps')); subpage.prefs = {arc: {enabled: {value: true}}};
}); subpage.androidAppsInfo = {
playStoreEnabled: false,
settingsAppAvailable: true,
};
Polymer.dom.flush();
test('ManageAppsOpenRequest', function() { const button = subpage.$$('#manageApps');
const button = appsPage.$$('#manageApps');
assertTrue(!!button); assertTrue(!!button);
const promise = const promise =
androidAppsBrowserProxy.whenCalled('showAndroidAppsSettings'); androidAppsBrowserProxy.whenCalled('showAndroidAppsSettings');
......
...@@ -116,31 +116,7 @@ TEST_F('OSSettingsAdvancedPageBrowserTest', 'DISABLED_AllJsTests', () => { ...@@ -116,31 +116,7 @@ TEST_F('OSSettingsAdvancedPageBrowserTest', 'DISABLED_AllJsTests', () => {
mocha.run(); mocha.run();
}); });
// Tests for the Android App section in Google Play Store. // Tests for the Apps section (combines Chrome and Android apps).
// eslint-disable-next-line no-var
var OSSettingsAndroidAppsPageTest = class extends OSSettingsBrowserTest {
/** @override */
get browsePreload() {
return super.browsePreload + 'android_apps_page/android_apps_page.html';
}
/** @override */
get extraLibraries() {
return super.extraLibraries.concat([
'//ui/webui/resources/js/promise_resolver.js',
BROWSER_SETTINGS_PATH + '../test_browser_proxy.js',
BROWSER_SETTINGS_PATH + 'chromeos/test_android_apps_browser_proxy.js',
'android_apps_page_test.js',
]);
}
};
// Disabled due to flakiness on linux-chromeos-rel
TEST_F('OSSettingsAndroidAppsPageTest', 'DISABLED_AllJsTests', () => {
mocha.run();
});
// Tests for the Android App section in Google Play Store.
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var OSSettingsAppsPageTest = class extends OSSettingsBrowserTest { var OSSettingsAppsPageTest = class extends OSSettingsBrowserTest {
/** @override */ /** @override */
......
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