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

Side by Side Diff: net/disk_cache/simple/simple_index_file_unittest.cc

Issue 100453006: Move Touch to base namespace, remove SetLastModifiedTime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/hash.h" 7 #include "base/hash.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 EXPECT_EQ(static_cast<int>(kDummyData.size()), 171 EXPECT_EQ(static_cast<int>(kDummyData.size()),
172 file_util::WriteFile(index_path, 172 file_util::WriteFile(index_path,
173 kDummyData.data(), 173 kDummyData.data(),
174 kDummyData.size())); 174 kDummyData.size()));
175 ASSERT_TRUE(simple_util::GetMTime(cache_path, &cache_mtime)); 175 ASSERT_TRUE(simple_util::GetMTime(cache_path, &cache_mtime));
176 EXPECT_FALSE( 176 EXPECT_FALSE(
177 WrappedSimpleIndexFile::LegacyIsIndexFileStale(cache_mtime, index_path)); 177 WrappedSimpleIndexFile::LegacyIsIndexFileStale(cache_mtime, index_path));
178 178
179 const base::Time past_time = base::Time::Now() - 179 const base::Time past_time = base::Time::Now() -
180 base::TimeDelta::FromSeconds(10); 180 base::TimeDelta::FromSeconds(10);
181 EXPECT_TRUE(file_util::TouchFile(index_path, past_time, past_time)); 181 EXPECT_TRUE(base::TouchFile(index_path, past_time, past_time));
182 EXPECT_TRUE(file_util::TouchFile(cache_path, past_time, past_time)); 182 EXPECT_TRUE(base::TouchFile(cache_path, past_time, past_time));
183 ASSERT_TRUE(simple_util::GetMTime(cache_path, &cache_mtime)); 183 ASSERT_TRUE(simple_util::GetMTime(cache_path, &cache_mtime));
184 EXPECT_FALSE( 184 EXPECT_FALSE(
185 WrappedSimpleIndexFile::LegacyIsIndexFileStale(cache_mtime, index_path)); 185 WrappedSimpleIndexFile::LegacyIsIndexFileStale(cache_mtime, index_path));
186 const base::Time even_older = past_time - base::TimeDelta::FromSeconds(10); 186 const base::Time even_older = past_time - base::TimeDelta::FromSeconds(10);
187 EXPECT_TRUE(file_util::TouchFile(index_path, even_older, even_older)); 187 EXPECT_TRUE(base::TouchFile(index_path, even_older, even_older));
188 EXPECT_TRUE( 188 EXPECT_TRUE(
189 WrappedSimpleIndexFile::LegacyIsIndexFileStale(cache_mtime, index_path)); 189 WrappedSimpleIndexFile::LegacyIsIndexFileStale(cache_mtime, index_path));
190 } 190 }
191 191
192 // This test is flaky, see http://crbug.com/255775. 192 // This test is flaky, see http://crbug.com/255775.
193 TEST_F(SimpleIndexFileTest, DISABLED_WriteThenLoadIndex) { 193 TEST_F(SimpleIndexFileTest, DISABLED_WriteThenLoadIndex) {
194 base::ScopedTempDir cache_dir; 194 base::ScopedTempDir cache_dir;
195 ASSERT_TRUE(cache_dir.CreateUniqueTempDir()); 195 ASSERT_TRUE(cache_dir.CreateUniqueTempDir());
196 196
197 SimpleIndex::EntrySet entries; 197 SimpleIndex::EntrySet entries;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 WrappedSimpleIndexFile::Deserialize(contents.data(), 336 WrappedSimpleIndexFile::Deserialize(contents.data(),
337 contents.size(), 337 contents.size(),
338 &when_index_last_saw_cache, 338 &when_index_last_saw_cache,
339 &deserialize_result); 339 &deserialize_result);
340 EXPECT_TRUE(deserialize_result.did_load); 340 EXPECT_TRUE(deserialize_result.did_load);
341 } 341 }
342 342
343 #endif // defined(OS_POSIX) 343 #endif // defined(OS_POSIX)
344 344
345 } // namespace disk_cache 345 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698