Index: chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js |
diff --git a/chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js b/chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js |
index f836ad4b647548a06d2127b2db141ff1560eea27..96ef0ca44ce6a9bb8a567d50fa07161bb07af472 100644 |
--- a/chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js |
+++ b/chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js |
@@ -5,6 +5,14 @@ |
var mockController; |
+WallpaperUtil.enabledExperimentalFeatureCallback = function(callback) { |
+ callback(); |
+}; |
+ |
+WallpaperUtil.enabledSyncThemesCallback = function(callback) { |
+ callback(); |
+}; |
+ |
function setUp() { |
mockController = new MockController(); |
installMockXMLHttpRequest(); |
@@ -14,6 +22,63 @@ function tearDown() { |
mockController.verifyMocks(); |
mockController.reset(); |
uninstallMockXMLHttpRequest(); |
+ mockSyncFS.reset(); |
+ mockLocalFS.reset(); |
+} |
+ |
+// Test set custom wallpaper from syncFS. When local wallpaper name is different |
+// with the name in server, wallpaper should use the one in server. |
+function testSyncCustomWallpaperSet() { |
+ var mockSetCustomWallpaper = mockController.createFunctionMock( |
+ chrome.wallpaperPrivate, 'setCustomWallpaper'); |
+ mockSetCustomWallpaper.addExpectation(TestConstants.fileString, |
+ 'dummy', |
+ true, |
+ 'dummy'); |
+ var syncFSChanges = {}; |
+ syncFSChanges.status = 'synced'; |
+ syncFSChanges.direction = 'remote_to_local'; |
+ syncFSChanges.action = 'added'; |
+ syncFSChanges.fileEntry = mockSyncFS.mockTestFile('dummy'); |
+ chrome.syncFileSystem.onFileStatusChanged.dispatch(syncFSChanges); |
+} |
+ |
+// Test store historical custom wallpaper. When receive a historical wallpaper |
+// from syncFS, we store it to local. |
+function testSyncCustoWallpapermStore() { |
+ var syncFSChanges = {}; |
+ syncFSChanges.status = 'synced'; |
+ syncFSChanges.direction = 'remote_to_local'; |
+ syncFSChanges.action = 'added'; |
+ syncFSChanges.fileEntry = mockSyncFS.mockTestFile('historicalwallpaper'); |
+ |
+ // TODO(ranj): support two callbacks with success and failure? |
+ var mockWrite = mockController.createFunctionMock(mockWriter, 'write'); |
+ mockWrite.addExpectation(new Blob([new Int8Array(TestConstants.fileString)])); |
+ chrome.syncFileSystem.onFileStatusChanged.dispatch(syncFSChanges); |
+} |
+ |
+// Test delete custom wallpaper from local. When receive a syncFS delete file |
+// event, delete the file in localFS as well. |
+function testSyncCustomWallpaperDelete() { |
+ var localOriginalPath = Constants.WallpaperDirNameEnum.ORIGINAL + '/' + |
+ 'deletewallpapername'; |
+ var localThumbnailPath = Constants.WallpaperDirNameEnum.THUMBNAIL + '/' + |
+ 'deletewallpapername'; |
+ var originalFE = mockLocalFS.mockTestFile(localOriginalPath); |
+ var thumbnailFE = mockLocalFS.mockTestFile(localThumbnailPath); |
+ var syncFSChanges = {}; |
+ syncFSChanges.status = 'synced'; |
+ syncFSChanges.direction = 'remote_to_local'; |
+ syncFSChanges.action = 'deleted'; |
+ syncFSChanges.fileEntry = new FileEntry('deletewallpapername'); |
+ var mockRemoveOriginal = mockController.createFunctionMock(originalFE, |
+ 'remove'); |
+ mockRemoveOriginal.addExpectation(function() {}, null); |
+ var mockRemoveThumbnail = mockController.createFunctionMock(thumbnailFE, |
+ 'remove'); |
+ mockRemoveThumbnail.addExpectation(function() {}, null); |
+ chrome.syncFileSystem.onFileStatusChanged.dispatch(syncFSChanges); |
} |
// Test sync online wallpaper. When the synced wallpaper info is not the same as |