Commit a52f7e9e authored by Julian Watson's avatar Julian Watson Committed by Commit Bot

crostini: cleanup page tests

Bug: None
Change-Id: Ifa311c32d0fa2a0d2cb7c13e107e98b7d046aeed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2082423Reviewed-by: default avatarJulian Watson <juwa@google.com>
Reviewed-by: default avatarNic Hollingum <hollingum@google.com>
Commit-Queue: Nic Hollingum <hollingum@google.com>
Auto-Submit: Julian Watson <juwa@google.com>
Cr-Commit-Position: refs/heads/master@{#746161}
parent 6f807ad1
...@@ -8,18 +8,20 @@ let crostiniPage = null; ...@@ -8,18 +8,20 @@ let crostiniPage = null;
/** @type {?TestCrostiniBrowserProxy} */ /** @type {?TestCrostiniBrowserProxy} */
let crostiniBrowserProxy = null; let crostiniBrowserProxy = null;
function setCrostiniPrefs( function setCrostiniPrefs(enabled, optional = {}) {
enabled, opt_sharedPaths, opt_sharedUsbDevices, opt_forwardedPorts) { const {sharedPaths = {}, sharedUsbDevices = [], forwardedPorts = []} =
optional;
crostiniPage.prefs = { crostiniPage.prefs = {
crostini: { crostini: {
enabled: {value: enabled}, enabled: {value: enabled},
port_forwarding: {ports: {value: opt_forwardedPorts || []}}, port_forwarding: {ports: {value: forwardedPorts}},
}, },
guest_os: { guest_os: {
paths_shared_to_vms: {value: opt_sharedPaths || {}}, paths_shared_to_vms: {value: sharedPaths},
}, },
}; };
crostiniBrowserProxy.sharedUsbDevices = opt_sharedUsbDevices || []; crostiniBrowserProxy.sharedUsbDevices = sharedUsbDevices;
Polymer.dom.flush(); Polymer.dom.flush();
} }
...@@ -74,13 +76,13 @@ suite('CrostiniPageTests', function() { ...@@ -74,13 +76,13 @@ suite('CrostiniPageTests', function() {
.then(() => { .then(() => {
assertFalse(button.disabled); assertFalse(button.disabled);
cr.webUIListenerCallback('crostini-installer-status-changed', true); cr.webUIListenerCallback('crostini-installer-status-changed', true);
flushAsync(); return flushAsync();
}) })
.then(() => { .then(() => {
assertTrue(button.disabled); assertTrue(button.disabled);
cr.webUIListenerCallback( cr.webUIListenerCallback(
'crostini-installer-status-changed', false); 'crostini-installer-status-changed', false);
flushAsync(); return flushAsync();
}) })
.then(() => { .then(() => {
assertFalse(button.disabled); assertFalse(button.disabled);
...@@ -286,20 +288,22 @@ suite('CrostiniPageTests', function() { ...@@ -286,20 +288,22 @@ suite('CrostiniPageTests', function() {
/** @type {?SettingsCrostiniPortForwarding} */ /** @type {?SettingsCrostiniPortForwarding} */
let subpage; let subpage;
setup(function() { setup(function() {
setCrostiniPrefs(true, {}, [], [ setCrostiniPrefs(true, {
{ forwardedPorts: [
'port_number': 5000, {
'protocol_type': 0, port_number: 5000,
'label': 'Label1', protocol_type: 0,
'active': true label: 'Label1',
}, active: true
{ },
'port_number': 5001, {
'protocol_type': 1, port_number: 5001,
'label': 'Label2', protocol_type: 1,
'active': false label: 'Label2',
}, active: false
]); },
]
});
return flushAsync() return flushAsync()
.then(() => { .then(() => {
...@@ -410,13 +414,18 @@ suite('CrostiniPageTests', function() { ...@@ -410,13 +414,18 @@ suite('CrostiniPageTests', function() {
// elements. // elements.
assertTrue(!!subpage.shadowRoot.querySelector('#remove').clientWidth); assertTrue(!!subpage.shadowRoot.querySelector('#remove').clientWidth);
cr.webUIListenerCallback('crostini-installer-status-changed', true); cr.webUIListenerCallback('crostini-installer-status-changed', true);
return flushAsync().then(() => { return flushAsync()
assertFalse(!!subpage.shadowRoot.querySelector('#remove').clientWidth); .then(() => {
cr.webUIListenerCallback('crostini-installer-status-changed', false); assertFalse(
return flushAsync().then(() => { !!subpage.shadowRoot.querySelector('#remove').clientWidth);
assertTrue(!!subpage.shadowRoot.querySelector('#remove').clientWidth); cr.webUIListenerCallback(
}); 'crostini-installer-status-changed', false);
}); return flushAsync();
})
.then(() => {
assertTrue(
!!subpage.shadowRoot.querySelector('#remove').clientWidth);
});
}); });
test('HideOnDisable', function() { test('HideOnDisable', function() {
...@@ -436,15 +445,18 @@ suite('CrostiniPageTests', function() { ...@@ -436,15 +445,18 @@ suite('CrostiniPageTests', function() {
let subpage; let subpage;
setup(function() { setup(function() {
setCrostiniPrefs(true, {'path1': ['termina'], 'path2': ['termina']}); setCrostiniPrefs(
return flushAsync().then(() => { true, {sharedPaths: {path1: ['termina'], path2: ['termina']}});
settings.Router.getInstance().navigateTo( return flushAsync()
settings.routes.CROSTINI_SHARED_PATHS); .then(() => {
return flushAsync().then(() => { settings.Router.getInstance().navigateTo(
subpage = crostiniPage.$$('settings-crostini-shared-paths'); settings.routes.CROSTINI_SHARED_PATHS);
assertTrue(!!subpage); return flushAsync();
}); })
}); .then(() => {
subpage = crostiniPage.$$('settings-crostini-shared-paths');
assertTrue(!!subpage);
});
}); });
test('Sanity', function() { test('Sanity', function() {
...@@ -464,7 +476,7 @@ suite('CrostiniPageTests', function() { ...@@ -464,7 +476,7 @@ suite('CrostiniPageTests', function() {
.then(([vmName, path]) => { .then(([vmName, path]) => {
assertEquals('termina', vmName); assertEquals('termina', vmName);
assertEquals('path1', path); assertEquals('path1', path);
setCrostiniPrefs(true, {'path2': ['termina']}); setCrostiniPrefs(true, {sharedPaths: {path2: ['termina']}});
return flushAsync(); return flushAsync();
}) })
.then(() => { .then(() => {
...@@ -481,7 +493,7 @@ suite('CrostiniPageTests', function() { ...@@ -481,7 +493,7 @@ suite('CrostiniPageTests', function() {
.then(([vmName, path]) => { .then(([vmName, path]) => {
assertEquals('termina', vmName); assertEquals('termina', vmName);
assertEquals('path2', path); assertEquals('path2', path);
setCrostiniPrefs(true, {}); setCrostiniPrefs(true, {sharedPaths: {}});
return flushAsync(); return flushAsync();
}) })
.then(() => { .then(() => {
...@@ -523,11 +535,13 @@ suite('CrostiniPageTests', function() { ...@@ -523,11 +535,13 @@ suite('CrostiniPageTests', function() {
let subpage; let subpage;
setup(function() { setup(function() {
setCrostiniPrefs(true, {}, [ setCrostiniPrefs(true, {
{'shared': true, 'guid': '0001', 'name': 'usb_dev1'}, sharedUsbDevices: [
{'shared': false, 'guid': '0002', 'name': 'usb_dev2'}, {shared: true, guid: '0001', name: 'usb_dev1'},
{'shared': true, 'guid': '0003', 'name': 'usb_dev3'} {shared: false, guid: '0002', name: 'usb_dev2'},
]); {shared: true, guid: '0003', name: 'usb_dev3'}
]
});
return flushAsync() return flushAsync()
.then(() => { .then(() => {
...@@ -560,7 +574,7 @@ suite('CrostiniPageTests', function() { ...@@ -560,7 +574,7 @@ suite('CrostiniPageTests', function() {
// Simulate a change in the underlying model. // Simulate a change in the underlying model.
cr.webUIListenerCallback('crostini-shared-usb-devices-changed', [ cr.webUIListenerCallback('crostini-shared-usb-devices-changed', [
{'shared': true, 'guid': '0001', 'name': 'usb_dev1'}, {shared: true, guid: '0001', name: 'usb_dev1'},
]); ]);
Polymer.dom.flush(); Polymer.dom.flush();
assertEquals( assertEquals(
......
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