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

Side by Side Diff: webkit/browser/database/database_tracker_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) 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 &database_size); 266 &database_size);
267 EXPECT_TRUE(base::CreateDirectory( 267 EXPECT_TRUE(base::CreateDirectory(
268 tracker->DatabaseDirectory().Append(base::FilePath::FromUTF16Unsafe( 268 tracker->DatabaseDirectory().Append(base::FilePath::FromUTF16Unsafe(
269 tracker->GetOriginDirectory(kOrigin1))))); 269 tracker->GetOriginDirectory(kOrigin1)))));
270 EXPECT_EQ(1, file_util::WriteFile( 270 EXPECT_EQ(1, file_util::WriteFile(
271 tracker->GetFullDBFilePath(kOrigin1, kDB1), "a", 1)); 271 tracker->GetFullDBFilePath(kOrigin1, kDB1), "a", 1));
272 tracker->DatabaseModified(kOrigin1, kDB1); 272 tracker->DatabaseModified(kOrigin1, kDB1);
273 273
274 // Setup file modification times. db1 and db2 are modified now, db3 three 274 // Setup file modification times. db1 and db2 are modified now, db3 three
275 // days ago. 275 // days ago.
276 EXPECT_TRUE(file_util::SetLastModifiedTime( 276 base::Time now = base::Time::Now();
277 tracker->GetFullDBFilePath(kOrigin1, kDB1), base::Time::Now())); 277 EXPECT_TRUE(base::TouchFile(tracker->GetFullDBFilePath(kOrigin1, kDB1),
278 EXPECT_TRUE(file_util::SetLastModifiedTime( 278 now, now));
279 tracker->GetFullDBFilePath(kOrigin2, kDB2), base::Time::Now())); 279 EXPECT_TRUE(base::TouchFile(tracker->GetFullDBFilePath(kOrigin2, kDB2),
280 base::Time three_days_ago = base::Time::Now(); 280 now, now));
281 three_days_ago -= base::TimeDelta::FromDays(3); 281 base::Time three_days_ago = now - base::TimeDelta::FromDays(3);
282 EXPECT_TRUE(file_util::SetLastModifiedTime( 282 EXPECT_TRUE(base::TouchFile(tracker->GetFullDBFilePath(kOrigin2, kDB3),
283 tracker->GetFullDBFilePath(kOrigin2, kDB3), three_days_ago)); 283 three_days_ago, three_days_ago));
284 284
285 // Delete databases modified since yesterday. db2 is whitelisted. 285 // Delete databases modified since yesterday. db2 is whitelisted.
286 base::Time yesterday = base::Time::Now(); 286 base::Time yesterday = base::Time::Now();
287 yesterday -= base::TimeDelta::FromDays(1); 287 yesterday -= base::TimeDelta::FromDays(1);
288 result = tracker->DeleteDataModifiedSince( 288 result = tracker->DeleteDataModifiedSince(
289 yesterday, callback.callback()); 289 yesterday, callback.callback());
290 EXPECT_EQ(net::ERR_IO_PENDING, result); 290 EXPECT_EQ(net::ERR_IO_PENDING, result);
291 ASSERT_FALSE(callback.have_result()); 291 ASSERT_FALSE(callback.have_result());
292 EXPECT_TRUE(observer.DidReceiveNewNotification()); 292 EXPECT_TRUE(observer.DidReceiveNewNotification());
293 tracker->DatabaseClosed(kOrigin1, kDB1); 293 tracker->DatabaseClosed(kOrigin1, kDB1);
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 868
869 TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) { 869 TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) {
870 DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid(); 870 DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid();
871 } 871 }
872 872
873 TEST(DatabaseTrackerTest, HandleSqliteError) { 873 TEST(DatabaseTrackerTest, HandleSqliteError) {
874 DatabaseTracker_TestHelper_Test::HandleSqliteError(); 874 DatabaseTracker_TestHelper_Test::HandleSqliteError();
875 } 875 }
876 876
877 } // namespace webkit_database 877 } // namespace webkit_database
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698