1 <!-- 2 Copyright 2013 The Chromium Authors. All rights reserved. 3 Use of this source code is governed by a BSD-style license that can be 4 found in the LICENSE file. 5 --> 6 <!DOCTYPE html> 7 <html> 8 <body> 9 <script> 10 window.chrome = {}; 11 12 var doNothing = function() {}; 13 14 var emptyClientRenderer = { 15 playerAdded: doNothing, 16 playerRemoved: doNothing, 17 playerUpdated: doNothing 18 }; 19 20 window.setUp = function() { 21 window.pm = new Manager(emptyClientRenderer); 22 }; 23 24 window.tearDown = function() { 25 window.pm = null; 26 }; 27 28 // Test a normal case of .addPlayer 29 window.testAddPlayer = function() { 30 window.pm.addPlayer('someid'); 31 assertTrue(undefined !== window.pm.players_['someid']); 32 }; 33 34 // On occasion, the backend will add an existing ID multiple times. 35 // make sure this doesn't break anything. 36 window.testAddPlayerAlreadyExisting = function() { 37 window.pm.addPlayer('someid'); 38 window.pm.addPlayer('someid'); 39 assertTrue(undefined !== window.pm.players_['someid']); 40 }; 41 42 // If the removal is set, make sure that a player 43 // gets removed from the PlayerManager. 44 window.testRemovePlayer = function() { 45 window.pm.addPlayer('someid'); 46 assertTrue(undefined !== window.pm.players_['someid']); 47 window.pm.removePlayer('someid'); 48 assertTrue(undefined === window.pm.players_['someid']); 49 }; 50 51 // Trying to select a non-existant player should throw 52 // an exception 53 window.testSelectNonExistant = function() { 54 assertThrows(function() { 55 window.pm.selectPlayer('someId'); 56 }); 57 }; 58 </script> 59 </body> 60 </html> 61