Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Unified Diff: chrome/test/data/webui/settings/fake_system_display.js

Issue 2084673003: MD Settings: Add display layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_547080_display_settings6
Patch Set: Nit Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/webui/settings/device_page_tests.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/settings/fake_system_display.js
diff --git a/chrome/test/data/webui/settings/fake_system_display.js b/chrome/test/data/webui/settings/fake_system_display.js
index 3fb8c35e7c986404885837ea52577f9aeac09300..aca85cc44eba6136f35854b717bc5729de7c98aa 100644
--- a/chrome/test/data/webui/settings/fake_system_display.js
+++ b/chrome/test/data/webui/settings/fake_system_display.js
@@ -14,7 +14,9 @@ cr.define('settings', function() {
function FakeSystemDisplay() {
/** @type {!Array<!chrome.system.display.DisplayUnitInfo>} */
this.fakeDisplays = [];
+ this.fakeLayouts = [];
this.getInfoCalled = new PromiseResolver();
+ this.getLayoutCalled = new PromiseResolver();
}
FakeSystemDisplay.prototype = {
@@ -22,7 +24,10 @@ cr.define('settings', function() {
/**
* @param {!chrome.system.display.DisplayUnitInfo>} display
*/
- addDisplayForTest: function(display) { this.fakeDisplays.push(display); },
+ addDisplayForTest: function(display) {
+ this.fakeDisplays.push(display);
+ this.updateLayouts_();
+ },
// SystemDisplay overrides.
/** @override */
@@ -57,13 +62,13 @@ cr.define('settings', function() {
}
if (info.mirroringSourceId != undefined) {
- for (var d of this.fakeDisplays)
+ for (let d of this.fakeDisplays)
d.mirroringSourceId = info.mirroringSourceId;
}
if (info.isPrimary != undefined) {
var havePrimary = info.isPrimary;
- for (var d of this.fakeDisplays) {
+ for (let d of this.fakeDisplays) {
if (d.id == id) {
d.isPrimary = info.isPrimary;
} else if (havePrimary) {
@@ -73,12 +78,30 @@ cr.define('settings', function() {
havePrimary = true;
}
}
+ this.updateLayouts_();
}
if (info.rotation != undefined)
display.rotation = info.rotation;
},
/** @override */
+ getDisplayLayout(callback) {
+ setTimeout(function() {
+ // Create a shallow copy to trigger Polymer data binding updates.
+ callback(this.fakeLayouts.slice());
+ this.getLayoutCalled.resolve();
+ // Reset the promise resolver.
+ this.getLayoutCalled = new PromiseResolver();
+ }.bind(this));
+ },
+
+ /** @override */
+ setDisplayLayout(layouts, callback) {
+ this.fakeLayouts = layouts;
+ callback();
+ },
+
+ /** @override */
onDisplayChanged: new FakeChromeEvent(),
/** @private */
@@ -89,6 +112,26 @@ cr.define('settings', function() {
if (idx >= 0)
return this.fakeDisplays[idx];
return undefined;
+ },
+
+ /** @private */
+ updateLayouts_() {
+ this.fakeLayouts = [];
+ var primaryId = '';
+ for (let d of this.fakeDisplays) {
+ if (d.isPrimary) {
+ primaryId = d.id;
+ break;
+ }
+ }
+ for (let d of this.fakeDisplays) {
+ this.fakeLayouts.push({
+ id: d.id,
+ parentId: d.isPrimary ? '' : primaryId,
+ position: chrome.system.display.LayoutPosition.RIGHT,
+ offset: 0
+ });
+ }
}
};
« no previous file with comments | « chrome/test/data/webui/settings/device_page_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698