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 |
+ }); |
+ } |
} |
}; |