OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/drive/sync_client.h" | 5 #include "chrome/browser/chromeos/drive/sync_client.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // The content of files stored in the service. | 42 // The content of files stored in the service. |
43 const char kRemoteContent[] = "World!"; | 43 const char kRemoteContent[] = "World!"; |
44 | 44 |
45 // SyncClientTestDriveService will return GDATA_CANCELLED when a request is | 45 // SyncClientTestDriveService will return GDATA_CANCELLED when a request is |
46 // made with the specified resource ID. | 46 // made with the specified resource ID. |
47 class SyncClientTestDriveService : public ::drive::FakeDriveService { | 47 class SyncClientTestDriveService : public ::drive::FakeDriveService { |
48 public: | 48 public: |
49 SyncClientTestDriveService() : download_file_count_(0) {} | 49 SyncClientTestDriveService() : download_file_count_(0) {} |
50 | 50 |
51 // FakeDriveService override: | 51 // FakeDriveService override: |
52 virtual google_apis::CancelCallback DownloadFile( | 52 google_apis::CancelCallback DownloadFile( |
53 const base::FilePath& local_cache_path, | 53 const base::FilePath& local_cache_path, |
54 const std::string& resource_id, | 54 const std::string& resource_id, |
55 const google_apis::DownloadActionCallback& download_action_callback, | 55 const google_apis::DownloadActionCallback& download_action_callback, |
56 const google_apis::GetContentCallback& get_content_callback, | 56 const google_apis::GetContentCallback& get_content_callback, |
57 const google_apis::ProgressCallback& progress_callback) override { | 57 const google_apis::ProgressCallback& progress_callback) override { |
58 ++download_file_count_; | 58 ++download_file_count_; |
59 if (resource_id == resource_id_to_be_cancelled_) { | 59 if (resource_id == resource_id_to_be_cancelled_) { |
60 base::MessageLoopProxy::current()->PostTask( | 60 base::MessageLoopProxy::current()->PostTask( |
61 FROM_HERE, | 61 FROM_HERE, |
62 base::Bind(download_action_callback, | 62 base::Bind(download_action_callback, |
(...skipping 30 matching lines...) Expand all Loading... |
93 int download_file_count_; | 93 int download_file_count_; |
94 std::string resource_id_to_be_cancelled_; | 94 std::string resource_id_to_be_cancelled_; |
95 std::string resource_id_to_be_paused_; | 95 std::string resource_id_to_be_paused_; |
96 base::Closure paused_action_; | 96 base::Closure paused_action_; |
97 }; | 97 }; |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 | 100 |
101 class SyncClientTest : public testing::Test { | 101 class SyncClientTest : public testing::Test { |
102 public: | 102 public: |
103 virtual void SetUp() override { | 103 void SetUp() override { |
104 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 104 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
105 | 105 |
106 pref_service_.reset(new TestingPrefServiceSimple); | 106 pref_service_.reset(new TestingPrefServiceSimple); |
107 test_util::RegisterDrivePrefs(pref_service_->registry()); | 107 test_util::RegisterDrivePrefs(pref_service_->registry()); |
108 | 108 |
109 fake_network_change_notifier_.reset( | 109 fake_network_change_notifier_.reset( |
110 new test_util::FakeNetworkChangeNotifier); | 110 new test_util::FakeNetworkChangeNotifier); |
111 | 111 |
112 logger_.reset(new EventLogger); | 112 logger_.reset(new EventLogger); |
113 | 113 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 local_id, google_apis::test_util::CreateCopyResultCallback(&error))); | 511 local_id, google_apis::test_util::CreateCopyResultCallback(&error))); |
512 | 512 |
513 base::RunLoop().RunUntilIdle(); | 513 base::RunLoop().RunUntilIdle(); |
514 | 514 |
515 // The callback is called. | 515 // The callback is called. |
516 EXPECT_EQ(FILE_ERROR_OK, error); | 516 EXPECT_EQ(FILE_ERROR_OK, error); |
517 } | 517 } |
518 | 518 |
519 } // namespace internal | 519 } // namespace internal |
520 } // namespace drive | 520 } // namespace drive |
OLD | NEW |