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

Unified Diff: chrome/test/data/extensions/api_test/dial/experimental/runtest.js

Issue 11444020: DIAL extension API skeleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: abc.... Created 8 years 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
Index: chrome/test/data/extensions/api_test/dial/experimental/runtest.js
diff --git a/chrome/test/data/extensions/api_test/dial/experimental/runtest.js b/chrome/test/data/extensions/api_test/dial/experimental/runtest.js
new file mode 100644
index 0000000000000000000000000000000000000000..a028f5ef360e520bda0435837f16b15298840125
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/dial/experimental/runtest.js
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Array of each device list update.
+var devices = [];
+
+chrome.test.sendMessage('ready', function(message) {
+ if (message == 'setup') {
+ function handleOnDeviceList(deviceList) {
+ var newDevices = [];
+ for (var i = 0; i < deviceList.length; ++i) {
+ newDevices.push(deviceList[i]);
+ }
+ devices.push(newDevices);
+ }
+ chrome.dial.onDeviceList.addListener(handleOnDeviceList);
+
+ chrome.test.sendMessage('setup', function(message) {
+ if (message == 'go') {
+ chrome.test.runTests([
+ function testEvents() {
+ // Make sure there were 3 devices.
+ chrome.test.assertEq(3, devices.length);
+
+ // Make sure each update contained 1 more device than the previous.
+ for (var i = 0; i < devices.length; ++i) {
+ chrome.test.assertEq(i + 1, devices[i].length);
+ }
+
+ // Just check the first device in the first update and the last
+ // device in the last update.
+ // Not exposing the device id right now.
+ chrome.test.assertTrue(!('deviceId' in devices[0][0]));
+ chrome.test.assertEq("1", devices[0][0].deviceLabel);
+ chrome.test.assertEq("http://1",
+ devices[0][0].deviceDescriptionUrl);
+
+ chrome.test.assertTrue(!('deviceId' in devices[2][2]));
+ chrome.test.assertEq("3", devices[2][2].deviceLabel);
+ chrome.test.assertEq("http://3",
+ devices[2][2].deviceDescriptionUrl);
+
+ chrome.test.succeed();
+ }
+ ]);
+ }
+ });
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698