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

Unified Diff: chrome/browser/chromeos/gdata/gdata_cache_unittest.cc

Issue 10834052: gdata: Add GDataCache::GetResourceIdsOfAllFiles() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « chrome/browser/chromeos/gdata/gdata_cache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc b/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
index b4805e5cbf60c8b05ae32f3c16665b41892c63be..94707bee9b1860b0b7f3ac8033d79695b56c1511 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_cache_unittest.cc
@@ -98,6 +98,21 @@ class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface {
MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64());
};
+// Copies results from GetResourceIdsOfBacklogCallback.
+void OnGetResourceIdsOfBacklog(std::vector<std::string>* out_to_fetch,
+ std::vector<std::string>* out_to_upload,
+ const std::vector<std::string>& to_fetch,
+ const std::vector<std::string>& to_upload) {
+ *out_to_fetch = to_fetch;
+ *out_to_upload = to_upload;
+}
+
+// Copies results from GetResourceIdsCallback.
+void OnGetResourceIds(std::vector<std::string>* out_resource_ids,
+ const std::vector<std::string>& resource_ids) {
+ *out_resource_ids = resource_ids;
+}
+
} // namespace
class GDataCacheTest : public testing::Test {
@@ -1395,4 +1410,55 @@ TEST_F(GDataCacheTest, MountUnmount) {
EXPECT_EQ(1, num_callback_invocations_);
}
+TEST_F(GDataCacheTest, GetResourceIdsOfBacklogOnUIThread) {
+ PrepareForInitCacheTest();
+
+ std::vector<std::string> to_fetch;
+ std::vector<std::string> to_upload;
+ cache_->GetResourceIdsOfBacklogOnUIThread(
+ base::Bind(&OnGetResourceIdsOfBacklog, &to_fetch, &to_upload));
+ test_util::RunBlockingPoolTask();
+
+ sort(to_fetch.begin(), to_fetch.end());
+ ASSERT_EQ(1U, to_fetch.size());
+ EXPECT_EQ("pinned:non-existent", to_fetch[0]);
+
+ sort(to_upload.begin(), to_upload.end());
+ ASSERT_EQ(2U, to_upload.size());
+ EXPECT_EQ("dirty:existing", to_upload[0]);
+ EXPECT_EQ("dirty_and_pinned:existing", to_upload[1]);
+}
+
+TEST_F(GDataCacheTest, GetResourceIdsOfExistingPinnedFilesOnUIThread) {
+ PrepareForInitCacheTest();
+
+ std::vector<std::string> resource_ids;
+ cache_->GetResourceIdsOfExistingPinnedFilesOnUIThread(
+ base::Bind(&OnGetResourceIds, &resource_ids));
+ test_util::RunBlockingPoolTask();
+
+ sort(resource_ids.begin(), resource_ids.end());
+ ASSERT_EQ(2U, resource_ids.size());
+ EXPECT_EQ("dirty_and_pinned:existing", resource_ids[0]);
+ EXPECT_EQ("pinned:existing", resource_ids[1]);
+}
+
+TEST_F(GDataCacheTest, GetResourceIdsOfAllFilesOnUIThread) {
+ PrepareForInitCacheTest();
+
+ std::vector<std::string> resource_ids;
+ cache_->GetResourceIdsOfAllFilesOnUIThread(
+ base::Bind(&OnGetResourceIds, &resource_ids));
+ test_util::RunBlockingPoolTask();
+
+ sort(resource_ids.begin(), resource_ids.end());
+ ASSERT_EQ(6U, resource_ids.size());
+ EXPECT_EQ("dirty:existing", resource_ids[0]);
+ EXPECT_EQ("dirty_and_pinned:existing", resource_ids[1]);
+ EXPECT_EQ("pinned:existing", resource_ids[2]);
+ EXPECT_EQ("pinned:non-existent", resource_ids[3]);
+ EXPECT_EQ("tmp:`~!@#$%^&*()-_=+[{|]}\\;',<.>/?", resource_ids[4]);
+ EXPECT_EQ("tmp:resource_id", resource_ids[5]);
+}
+
} // namespace gdata
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698