Index: chrome/browser/content_settings/content_settings_pref_provider_unittest.cc |
diff --git a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc |
index 395693a0782db70316d798221e854a161f4b7540..a090372ad47d3c5ac6d267e2d5123611a9519fe7 100644 |
--- a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc |
+++ b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc |
@@ -14,6 +14,7 @@ |
#include "base/prefs/pref_service.h" |
#include "base/prefs/scoped_user_pref_update.h" |
#include "base/prefs/testing_pref_store.h" |
+#include "base/test/simple_test_clock.h" |
#include "base/threading/platform_thread.h" |
#include "base/values.h" |
#include "chrome/browser/content_settings/content_settings_mock_observer.h" |
@@ -444,4 +445,39 @@ TEST_F(PrefProviderTest, Deadlock) { |
provider.ShutdownOnUIThread(); |
} |
+TEST_F(PrefProviderTest, LastUsage) { |
+ TestingProfile testing_profile; |
+ PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), |
+ false); |
+ base::SimpleTestClock* test_clock = new base::SimpleTestClock; |
Bernhard Bauer
2014/07/17 09:11:48
Alternatively, make this a scoped_ptr<base::Simple
Daniel Nishi
2014/07/17 18:01:49
Thanks for the suggestion, but I think I'm going t
|
+ test_clock->SetNow(base::Time::Now()); |
+ |
+ pref_content_settings_provider.SetClockForTesting( |
+ scoped_ptr<base::Clock>(test_clock)); |
+ GURL host("http://example.com/"); |
+ ContentSettingsPattern pattern = |
+ ContentSettingsPattern::FromString("[*.]example.com"); |
+ |
+ base::Time no_usage = pref_content_settings_provider.GetLastUsage( |
+ pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION); |
+ EXPECT_EQ(no_usage.ToDoubleT(), 0); |
+ |
+ pref_content_settings_provider.UpdateLastUsage( |
+ pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION); |
+ base::Time first = pref_content_settings_provider.GetLastUsage( |
+ pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION); |
+ |
+ test_clock->Advance(base::TimeDelta::FromSeconds(10)); |
+ |
+ pref_content_settings_provider.UpdateLastUsage( |
+ pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION); |
+ base::Time second = pref_content_settings_provider.GetLastUsage( |
+ pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION); |
+ |
+ base::TimeDelta delta = second - first; |
+ EXPECT_EQ(delta.InSeconds(), 10); |
+ |
+ pref_content_settings_provider.ShutdownOnUIThread(); |
+} |
+ |
} // namespace content_settings |