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

Unified Diff: chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc

Issue 11699004: Add automated test for chrome.onFileSynced JavsScript event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Kinuko Review #2 Created 7 years, 11 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/sync_file_system/on_file_synced/manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc b/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
index 8098c32893e912f4abee42533243508940f806ce..4cefacc11fb4db08148d144374c634f49ee07400 100644
--- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
+++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
@@ -14,6 +14,7 @@
#include "chrome/common/extensions/features/feature.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/fileapi/file_system_url.h"
#include "webkit/fileapi/syncable/sync_status_code.h"
#include "webkit/quota/quota_manager.h"
@@ -68,6 +69,23 @@ ACTION_P(NotifyOkStateAndCallback, mock_remote_service) {
FROM_HERE, base::Bind(arg1, fileapi::SYNC_STATUS_OK));
}
+ACTION_P2(UpdateRemoteChangeQueue, origin, mock_remote_service) {
+ *origin = arg0;
+ mock_remote_service->NotifyRemoteChangeQueueUpdated(1);
+}
+
+ACTION_P2(ReturnWithFakeFileAddedStatus, origin, mock_remote_service) {
+ fileapi::FileSystemURL mock_url(*origin,
+ fileapi::kFileSystemTypeTest,
+ FilePath(FILE_PATH_LITERAL("foo")));
+ mock_remote_service->NotifyRemoteChangeQueueUpdated(0);
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE, base::Bind(arg1,
+ fileapi::SYNC_STATUS_OK,
+ mock_url,
+ fileapi::SYNC_OPERATION_ADDED));
+}
+
} // namespace
// TODO(calvinlo): Add Chrome OS support for syncable file system
@@ -90,9 +108,20 @@ IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetUsageAndQuota) {
<< message_;
}
+IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnFileSynced) {
+ // Mock a pending remote change to be synced.
+ GURL origin;
+ EXPECT_CALL(*mock_remote_service(), RegisterOriginForTrackingChanges(_, _))
+ .WillOnce(UpdateRemoteChangeQueue(&origin, mock_remote_service()));
+ EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _))
+ .WillOnce(ReturnWithFakeFileAddedStatus(&origin,
+ mock_remote_service()));
+ ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_file_synced"))
+ << message_;
+}
+
IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnSyncStateChanged) {
- EXPECT_CALL(*mock_remote_service(),
- RegisterOriginForTrackingChanges(_, _))
+ EXPECT_CALL(*mock_remote_service(), RegisterOriginForTrackingChanges(_, _))
.WillOnce(NotifyOkStateAndCallback(mock_remote_service()));
ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_sync_state_changed"))
<< message_;
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/sync_file_system/on_file_synced/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698