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

Unified Diff: chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js

Issue 642943002: Add tests for sync custom wallpaper feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issues from 2nd code review Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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);
}
bshe 2014/10/28 22:34:57 Is it possible to add a test that a new custom wal
Ran 2014/10/29 19:13:13 Not possible for now as the FS operations takes tw
bshe 2014/10/30 12:51:36 never mind. you can do it in a separate CL.
// Test sync online wallpaper. When the synced wallpaper info is not the same as

Powered by Google App Engine
This is Rietveld 408576698