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

Unified Diff: ui/file_manager/file_manager/common/js/importer_common_unittest.js

Issue 945933003: Add support for log file rotation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge w/ master. Created 5 years, 10 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: ui/file_manager/file_manager/common/js/importer_common_unittest.js
diff --git a/ui/file_manager/file_manager/common/js/importer_common_unittest.js b/ui/file_manager/file_manager/common/js/importer_common_unittest.js
index c531c16db683d069020274ef832a16cf1fa94eae..9018108d3f9554563bf1c2aa7f0bfd3f32d11084 100644
--- a/ui/file_manager/file_manager/common/js/importer_common_unittest.js
+++ b/ui/file_manager/file_manager/common/js/importer_common_unittest.js
@@ -174,6 +174,55 @@ function testLocalStorageWrapper(callback) {
reportPromise(promise, callback);
}
+function testRotateLogs(callback) {
+ var fileName;
+ var fileFactory = function(namePromise) {
+ return namePromise.then(
+ function(name) {
+ fileName = name;
+ return Promise.resolve(driveFileEntry);
+ });
+ };
+
+ var nextLogId = 0;
+ var lastLogId = 1;
+ var promise = importer.ChromeLocalStorage.getInstance()
+ .set(importer.Setting.LAST_KNOWN_LOG_ID, lastLogId)
+ .then(
+ function() {
+ // Should delete the log with the nextLogId.
+ return importer.rotateLogs(nextLogId, fileFactory);
+ })
+ .then(
+ function() {
+ assertTrue(fileName !== undefined);
+ // Verify the *active* log is deleted.
+ assertEquals(0, fileName.search(/import-debug-[0-9]{6}-0.log/),
+ 'Filename (' + fileName + ') does not match next pattern.');
+ driveFileEntry.assertRemoved();
+
+ return importer.ChromeLocalStorage.getInstance()
+ .get(importer.Setting.LAST_KNOWN_LOG_ID)
+ .then(assertEquals.bind(null, nextLogId));
+ });
+
+ reportPromise(promise, callback);
+}
+
+function testRotateLogs_RemembersInitialActiveLog(callback) {
+ var nextLogId = 1;
+ var fileFactory = assertFalse; // Should not be called.
+ var promise = importer.rotateLogs(nextLogId, assertFalse)
+ .then(
+ function() {
+ return importer.ChromeLocalStorage.getInstance()
+ .get(importer.Setting.LAST_KNOWN_LOG_ID)
+ .then(assertEquals.bind(null, nextLogId));
+ });
+
+ reportPromise(promise, callback);
+}
+
/** @param {string} path */
function assertIsMediaDir(path) {
var dir = createDirectoryEntry(sdVolume, path);
« no previous file with comments | « ui/file_manager/file_manager/common/js/importer_common.js ('k') | ui/file_manager/file_manager/common/js/mock_entry.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698