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

Unified Diff: chrome/browser/chromeos/drive/file_system_unittest.cc

Issue 16628003: drive: Remove FileCacheObserver::OnCacheCommitted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/browser/chromeos/drive/file_system_unittest.cc
diff --git a/chrome/browser/chromeos/drive/file_system_unittest.cc b/chrome/browser/chromeos/drive/file_system_unittest.cc
index ae5b8590e93e9b89ace270f8ec8012e3983ae5bb..faf2af316f5cfc59d0adbf02595dcc671fdb216e 100644
--- a/chrome/browser/chromeos/drive/file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system_unittest.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/chromeos/drive/job_scheduler.h"
#include "chrome/browser/chromeos/drive/mock_directory_change_observer.h"
#include "chrome/browser/chromeos/drive/mock_file_cache_observer.h"
+#include "chrome/browser/chromeos/drive/sync_client.h"
#include "chrome/browser/chromeos/drive/test_util.h"
#include "chrome/browser/google_apis/drive_api_parser.h"
#include "chrome/browser/google_apis/fake_drive_service.h"
@@ -119,6 +120,10 @@ class FileSystemTest : public testing::Test {
file_system_->AddObserver(mock_directory_observer_.get());
file_system_->Initialize();
+ // Disable delaying so that the sync starts immediately.
+ file_system_->sync_client_->set_delay_for_testing(
+ base::TimeDelta::FromSeconds(0));
+
FileError error = FILE_ERROR_FAILED;
resource_metadata_->Initialize(
google_apis::test_util::CreateCopyResultCallback(&error));
@@ -725,17 +730,13 @@ TEST_F(FileSystemTest, OpenAndCloseFile) {
// The transfered file is cached and the change of "offline available"
// attribute is notified.
EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1);
+ Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(AtLeast(1));
const base::FilePath kFileInRoot(FILE_PATH_LITERAL("drive/root/File 1.txt"));
scoped_ptr<ResourceEntry> entry(GetResourceEntryByPathSync(kFileInRoot));
const std::string& file_resource_id = entry->resource_id();
const std::string& md5 = entry->file_specific_info().md5();
- // A dirty file is created on close.
- EXPECT_CALL(*mock_cache_observer_, OnCacheCommitted(file_resource_id))
- .Times(1);
-
// Open kFileInRoot ("drive/root/File 1.txt").
FileError error = FILE_ERROR_FAILED;
base::FilePath file_path;
@@ -778,6 +779,11 @@ TEST_F(FileSystemTest, OpenAndCloseFile) {
EXPECT_EQ(FILE_ERROR_OK, error);
EXPECT_EQ(cache_file_path, opened_file_path);
+ // Write a new content.
+ const std::string kNewContent = kExpectedContent + kExpectedContent;
+ EXPECT_TRUE(google_apis::test_util::WriteStringToFile(cache_file_path,
+ kNewContent));
+
// Close kFileInRoot ("drive/root/File 1.txt").
file_system_->CloseFile(
kFileInRoot,
@@ -787,12 +793,10 @@ TEST_F(FileSystemTest, OpenAndCloseFile) {
// Verify that the file was properly closed.
EXPECT_EQ(FILE_ERROR_OK, error);
- // Verify that the cache state was changed as expected.
- EXPECT_TRUE(GetCacheEntryFromOriginThread(file_resource_id, md5,
- &cache_entry));
- EXPECT_TRUE(cache_entry.is_present());
- EXPECT_TRUE(cache_entry.is_dirty());
- EXPECT_TRUE(cache_entry.is_persistent());
+ // Verify that the file was synced as expected.
+ entry = GetResourceEntryByPathSync(kFileInRoot);
kinaba 2013/06/11 07:08:37 GetResourceEntryByPathSync ends up with local reso
hashimoto 2013/06/11 07:37:57 Good catch, I should have checked the change stamp
+ ASSERT_TRUE(entry);
+ EXPECT_EQ(static_cast<int>(kNewContent.size()), entry->file_info().size());
// Try to close the same file twice.
file_system_->CloseFile(

Powered by Google App Engine
This is Rietveld 408576698