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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
11 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 11 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
12 #include "chrome/browser/chromeos/gdata/gdata_cache.h" | 12 #include "chrome/browser/chromeos/gdata/gdata_cache.h" |
13 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | 13 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
14 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" | 14 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
15 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 15 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 16 #include "chrome/browser/chromeos/gdata/mock_gdata_cache_observer.h" |
16 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
18 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 using ::testing::AtLeast; | 23 using ::testing::AtLeast; |
23 using ::testing::Return; | 24 using ::testing::Return; |
24 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
25 | 26 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 FilePath path_to_scan; | 91 FilePath path_to_scan; |
91 FilePath expected_existing_path; | 92 FilePath expected_existing_path; |
92 }; | 93 }; |
93 | 94 |
94 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface { | 95 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface { |
95 public: | 96 public: |
96 virtual ~MockFreeDiskSpaceGetter() {} | 97 virtual ~MockFreeDiskSpaceGetter() {} |
97 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64()); | 98 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64()); |
98 }; | 99 }; |
99 | 100 |
100 class MockGDataCacheObserver : public GDataCache::Observer { | |
101 public: | |
102 MOCK_METHOD2(OnCachePinned, void(const std::string& resource_id, | |
103 const std::string& md5)); | |
104 MOCK_METHOD2(OnCacheUnpinned, void(const std::string& resource_id, | |
105 const std::string& md5)); | |
106 MOCK_METHOD1(OnCacheCommitted, void(const std::string& resource_id)); | |
107 }; | |
108 | |
109 } // namespace | 101 } // namespace |
110 | 102 |
111 class GDataCacheTest : public testing::Test { | 103 class GDataCacheTest : public testing::Test { |
112 protected: | 104 protected: |
113 GDataCacheTest() | 105 GDataCacheTest() |
114 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 106 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
115 io_thread_(content::BrowserThread::IO), | 107 io_thread_(content::BrowserThread::IO), |
116 cache_(NULL), | 108 cache_(NULL), |
117 num_callback_invocations_(0), | 109 num_callback_invocations_(0), |
118 expected_error_(GDATA_FILE_OK), | 110 expected_error_(GDATA_FILE_OK), |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 EXPECT_EQ(1, num_callback_invocations_); | 1389 EXPECT_EQ(1, num_callback_invocations_); |
1398 EXPECT_TRUE(CacheEntryExists(resource_id, md5)); | 1390 EXPECT_TRUE(CacheEntryExists(resource_id, md5)); |
1399 | 1391 |
1400 // Try to remove the file. | 1392 // Try to remove the file. |
1401 num_callback_invocations_ = 0; | 1393 num_callback_invocations_ = 0; |
1402 TestRemoveFromCache(resource_id, GDATA_FILE_OK); | 1394 TestRemoveFromCache(resource_id, GDATA_FILE_OK); |
1403 EXPECT_EQ(1, num_callback_invocations_); | 1395 EXPECT_EQ(1, num_callback_invocations_); |
1404 } | 1396 } |
1405 | 1397 |
1406 } // namespace gdata | 1398 } // namespace gdata |
OLD | NEW |