| OLD | NEW |
| (Empty) |
| 1 // Copyright 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 'use strict'; | |
| 5 | |
| 6 var mockController; | |
| 7 | |
| 8 function setUp() { | |
| 9 mockController = new MockController(); | |
| 10 installMockXMLHttpRequest(); | |
| 11 } | |
| 12 | |
| 13 function tearDown() { | |
| 14 mockController.verifyMocks(); | |
| 15 mockController.reset(); | |
| 16 uninstallMockXMLHttpRequest(); | |
| 17 } | |
| 18 | |
| 19 // Test sync online wallpaper. When the synced wallpaper info is not the same as | |
| 20 // the local wallpaper info, wallpaper should set to the synced one. | |
| 21 function testSyncOnlineWallpaper() { | |
| 22 // Setup sync value. | |
| 23 var changes = {}; | |
| 24 changes[Constants.AccessSyncWallpaperInfoKey] = {}; | |
| 25 changes[Constants.AccessSyncWallpaperInfoKey].newValue = { | |
| 26 'url': TestConstants.wallpaperURL, | |
| 27 'layout': 'custom', | |
| 28 'source': Constants.WallpaperSourceEnum.Online | |
| 29 }; | |
| 30 | |
| 31 chrome.wallpaperPrivate = {}; | |
| 32 var mockSetWallpaperIfExists = mockController.createFunctionMock( | |
| 33 chrome.wallpaperPrivate, 'setWallpaperIfExists'); | |
| 34 mockSetWallpaperIfExists.addExpectation( | |
| 35 changes[Constants.AccessSyncWallpaperInfoKey].newValue.url, | |
| 36 changes[Constants.AccessSyncWallpaperInfoKey].newValue.layout); | |
| 37 mockSetWallpaperIfExists.callbackData = [false]; | |
| 38 | |
| 39 var mockSetWallpaper = mockController.createFunctionMock( | |
| 40 chrome.wallpaperPrivate, 'setWallpaper'); | |
| 41 mockSetWallpaper.addExpectation( | |
| 42 TestConstants.image, | |
| 43 changes[Constants.AccessSyncWallpaperInfoKey].newValue.layout, | |
| 44 changes[Constants.AccessSyncWallpaperInfoKey].newValue.url); | |
| 45 | |
| 46 chrome.storage.onChanged.dispatch(changes); | |
| 47 } | |
| OLD | NEW |