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 <errno.h> | 5 #include <errno.h> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 522 |
523 RunAllPendingForIO(); | 523 RunAllPendingForIO(); |
524 } | 524 } |
525 | 525 |
526 void TestGetCacheState(const std::string& resource_id, const std::string& md5, | 526 void TestGetCacheState(const std::string& resource_id, const std::string& md5, |
527 base::PlatformFileError expected_error, | 527 base::PlatformFileError expected_error, |
528 int expected_cache_state, GDataFile* expected_file) { | 528 int expected_cache_state, GDataFile* expected_file) { |
529 expected_error_ = expected_error; | 529 expected_error_ = expected_error; |
530 expected_cache_state_ = expected_cache_state; | 530 expected_cache_state_ = expected_cache_state; |
531 | 531 |
532 { // Lock to use GetCacheState, but release before flushing tasks because | 532 file_system_->GetCacheState(resource_id, md5, |
533 // OnGetCacheState callback will attempt to lock. | 533 base::Bind(&GDataFileSystemTest::VerifyGetCacheState, |
534 base::AutoLock lock(file_system_->lock_); | 534 base::Unretained(this))); |
535 file_system_->GetCacheState(resource_id, md5, | |
536 base::Bind(&GDataFileSystemTest::VerifyGetCacheState, | |
537 base::Unretained(this))); | |
538 } | |
539 | 535 |
540 RunAllPendingForIO(); | 536 RunAllPendingForIO(); |
541 } | 537 } |
542 | 538 |
543 void VerifyGetCacheState(base::PlatformFileError error, int cache_state) { | 539 void VerifyGetCacheState(base::PlatformFileError error, int cache_state) { |
544 ++num_callback_invocations_; | 540 ++num_callback_invocations_; |
545 | 541 |
546 EXPECT_EQ(expected_error_, error); | 542 EXPECT_EQ(expected_error_, error); |
547 | 543 |
548 if (error == base::PLATFORM_FILE_OK) { | 544 if (error == base::PLATFORM_FILE_OK) { |
(...skipping 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2955 EXPECT_EQ(1, num_callback_invocations_); | 2951 EXPECT_EQ(1, num_callback_invocations_); |
2956 EXPECT_TRUE(CacheEntryExists(resource_id, md5)); | 2952 EXPECT_TRUE(CacheEntryExists(resource_id, md5)); |
2957 | 2953 |
2958 // Try to remove the file. | 2954 // Try to remove the file. |
2959 num_callback_invocations_ = 0; | 2955 num_callback_invocations_ = 0; |
2960 TestRemoveFromCache(resource_id, base::PLATFORM_FILE_OK); | 2956 TestRemoveFromCache(resource_id, base::PLATFORM_FILE_OK); |
2961 EXPECT_EQ(1, num_callback_invocations_); | 2957 EXPECT_EQ(1, num_callback_invocations_); |
2962 } | 2958 } |
2963 | 2959 |
2964 } // namespace gdata | 2960 } // namespace gdata |
OLD | NEW |