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

Side by Side Diff: mojo/spy/ui/spy_test.js

Issue 278703002: Initial mojo spy skeleton based on tvcm (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready to land Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 tvcm.require('ui.spy');
8 tvcm.require('tvcm.event_target');
9
10 tvcm.unittest.testSuite('ui.spy_test', function() {
11 /**
12 * @constructor
13 */
14 function FakeChannel() {
15 tvcm.EventTarget.call(this);
16 }
17
18 FakeChannel.prototype = {
19 __proto__: tvcm.EventTarget.prototype,
20
21 send: function(msg) {
22 },
23
24 dispatchMessage: function(msg) {
25 var event = new Event('message', false, false);
26 event.data = msg;
27 this.dispatchEvent(event);
28 }
29 };
30
31 test('basic', function() {
32 var channel = new FakeChannel();
33
34 var spy = new ui.Spy();
35 spy.style.width = '600px';
36 spy.style.height = '400px';
37 spy.style.border = '1px solid black';
38 this.addHTMLOutput(spy);
39 spy.channel = channel;
40
41 channel.dispatchMessage({data: 'alo there'});
42
43 // Fake out echo reply
44 channel.send = function(msg) {
45 setTimeout(function() {
46 channel.dispatchMessage({data: {type: 'reply', msg: msg}});
47 }, 10);
48 }
49 });
50
51 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698