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 @@
on-click="onManageAndroidAppsTap_" external></cr-link-row>
</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="androidRemoveLabel" class="start">
$i18n{androidAppsRemove}
......
......@@ -36,10 +36,6 @@ suite('AndroidAppsPageTests', function() {
androidAppsPage.remove();
});
teardown(function() {
androidAppsPage.remove();
});
suite('Main Page', function() {
setup(function() {
androidAppsPage.havePlayStoreApp = true;
......
......@@ -8,18 +8,10 @@ let appsPage = null;
/** @type {?TestAndroidAppsBrowserProxy} */
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() {
setup(function() {
androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy();
settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy;
PolymerTest.clearBody();
appsPage = document.createElement('os-settings-apps-page');
document.body.appendChild(appsPage);
......@@ -28,6 +20,7 @@ suite('AppsPageTests', function() {
teardown(function() {
appsPage.remove();
appsPage = null;
});
suite('Page Combinations', function() {
......@@ -75,31 +68,20 @@ suite('AppsPageTests', function() {
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() {
setup(function() {
appsPage.showAndroidApps = true;
appsPage.havePlayStoreApp = true;
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');
assertTrue(!!button);
assertFalse(!!appsPage.$$('.subpage-arrow'));
......@@ -108,45 +90,40 @@ suite('AndroidAppsDetailPageTests', function() {
Polymer.dom.flush();
assertTrue(appsPage.prefs.arc.enabled.value);
setAndroidAppsState(true, false);
appsPage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: false,
};
Polymer.dom.flush();
assertTrue(!!appsPage.$$('.subpage-arrow'));
});
});
// TODO(crbug.com/1006662): Fix test suite.
suite.skip('SubPage', function() {
let subpage;
function flushAsync() {
Polymer.dom.flush();
return new Promise(resolve => {
appsPage.async(resolve);
// TODO(crbug.com/1006662): Test that setting playStoreEnabled to false
// navigates back to the main apps section.
});
}
/**
* 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();
});
});
}
suite('Android apps subpage', function() {
let subpage = null;
setup(function() {
appsPage.havePlayStoreApp = true;
appsPage.prefs = {arc: {enabled: {value: true}}};
setAndroidAppsState(true, false);
settings.navigateTo(settings.routes.ANDROID_APPS);
appsPage.$$('#android-apps').click();
return flushAsync().then(() => {
subpage = appsPage.$$('settings-android-apps-subpage');
assertTrue(!!subpage);
androidAppsBrowserProxy = new TestAndroidAppsBrowserProxy();
settings.AndroidAppsBrowserProxyImpl.instance_ = androidAppsBrowserProxy;
PolymerTest.clearBody();
subpage = document.createElement('settings-android-apps-subpage');
document.body.appendChild(subpage);
testing.Test.disableAnimationsAndTransitions();
subpage.prefs = {arc: {enabled: {value: true}}};
subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: false,
};
Polymer.dom.flush();
});
teardown(function() {
subpage.remove();
subpage = null;
});
test('Sanity', function() {
......@@ -156,14 +133,27 @@ suite('AndroidAppsDetailPageTests', function() {
test('ManageAppsUpdate', function() {
assertTrue(!subpage.$$('#manageApps'));
setAndroidAppsState(true, true);
subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: true,
};
Polymer.dom.flush();
assertTrue(!!subpage.$$('#manageApps'));
setAndroidAppsState(true, false);
subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: false,
};
Polymer.dom.flush();
assertTrue(!subpage.$$('#manageApps'));
});
test('ManageAppsOpenRequest', function() {
setAndroidAppsState(true, true);
subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: true,
};
Polymer.dom.flush();
const button = subpage.$$('#manageApps');
assertTrue(!!button);
const promise =
......@@ -187,23 +177,8 @@ suite('AndroidAppsDetailPageTests', function() {
dialog.close();
});
test('HideOnDisable', function() {
assertEquals(
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 = {
test('ARC enabled by policy', function() {
subpage.prefs = {
arc: {
enabled: {
value: true,
......@@ -211,34 +186,25 @@ suite('AndroidAppsDetailPageTests', function() {
}
}
};
setAndroidAppsState(true, true);
assertTrue(!!settings.routes.ANDROID_APPS_DETAILS);
appsPage.$$('#android-apps').click();
subpage.androidAppsInfo = {
playStoreEnabled: true,
settingsAppAvailable: true,
};
Polymer.dom.flush();
subpage = appsPage.$$('settings-android-apps-subpage');
assertTrue(!!subpage);
});
test('Sanity', function(done) {
Polymer.dom.flush();
assertFalse(!!subpage.$$('#remove'));
assertTrue(!!subpage.$$('#manageApps'));
});
});
suite('NoPlayStore', function() {
setup(function() {
appsPage.havePlayStoreApp = false;
appsPage.prefs = {arc: {enabled: {value: true}}};
setAndroidAppsState(true, true);
});
test('Sanity', function() {
assertTrue(!!appsPage.$$('#manageApps'));
});
test('Can open app settings without Play Store', function() {
subpage.prefs = {arc: {enabled: {value: true}}};
subpage.androidAppsInfo = {
playStoreEnabled: false,
settingsAppAvailable: true,
};
Polymer.dom.flush();
test('ManageAppsOpenRequest', function() {
const button = appsPage.$$('#manageApps');
const button = subpage.$$('#manageApps');
assertTrue(!!button);
const promise =
androidAppsBrowserProxy.whenCalled('showAndroidAppsSettings');
......
......@@ -116,31 +116,7 @@ TEST_F('OSSettingsAdvancedPageBrowserTest', 'DISABLED_AllJsTests', () => {
mocha.run();
});
// Tests for the Android App section in Google Play Store.
// 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.
// Tests for the Apps section (combines Chrome and Android apps).
// eslint-disable-next-line no-var
var OSSettingsAppsPageTest = class extends OSSettingsBrowserTest {
/** @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