OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "net/disk_cache/disk_cache_test_base.h" | 8 #include "net/disk_cache/disk_cache_test_base.h" |
9 #include "net/disk_cache/disk_cache_test_util.h" | 9 #include "net/disk_cache/disk_cache_test_util.h" |
10 #include "net/disk_cache/mapped_file.h" | 10 #include "net/disk_cache/mapped_file.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 // Implementation of FileIOCallback for the tests. | 15 // Implementation of FileIOCallback for the tests. |
16 class FileCallbackTest: public disk_cache::FileIOCallback { | 16 class FileCallbackTest: public disk_cache::FileIOCallback { |
17 public: | 17 public: |
18 explicit FileCallbackTest(int id, | 18 FileCallbackTest(int id, MessageLoopHelper* helper, int* max_id) |
19 MessageLoopHelper* helper, | |
20 int* max_id) | |
21 : id_(id), | 19 : id_(id), |
22 helper_(helper), | 20 helper_(helper), |
23 max_id_(max_id) { | 21 max_id_(max_id) { |
24 } | 22 } |
25 virtual ~FileCallbackTest() {} | 23 virtual ~FileCallbackTest() {} |
26 | 24 |
27 virtual void OnFileIOComplete(int bytes_copied); | 25 virtual void OnFileIOComplete(int bytes_copied); |
28 | 26 |
29 private: | 27 private: |
30 int id_; | 28 int id_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 &completed)); | 82 &completed)); |
85 if (!completed) | 83 if (!completed) |
86 expected++; | 84 expected++; |
87 | 85 |
88 helper.WaitUntilCacheIoFinished(expected); | 86 helper.WaitUntilCacheIoFinished(expected); |
89 | 87 |
90 EXPECT_EQ(expected, helper.callbacks_called()); | 88 EXPECT_EQ(expected, helper.callbacks_called()); |
91 EXPECT_FALSE(helper.callback_reused_error()); | 89 EXPECT_FALSE(helper.callback_reused_error()); |
92 EXPECT_STREQ(buffer1, buffer2); | 90 EXPECT_STREQ(buffer1, buffer2); |
93 } | 91 } |
OLD | NEW |