| 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 "chrome/browser/content_settings/content_settings_pref_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/prefs/default_pref_store.h" | 11 #include "base/prefs/default_pref_store.h" |
| 12 #include "base/prefs/overlay_user_pref_store.h" | 12 #include "base/prefs/overlay_user_pref_store.h" |
| 13 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "base/prefs/scoped_user_pref_update.h" | 15 #include "base/prefs/scoped_user_pref_update.h" |
| 16 #include "base/prefs/testing_pref_store.h" | 16 #include "base/prefs/testing_pref_store.h" |
| 17 #include "base/test/simple_test_clock.h" | 17 #include "base/test/simple_test_clock.h" |
| 18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/content_settings/content_settings_mock_observer.h" | 20 #include "chrome/browser/content_settings/content_settings_mock_observer.h" |
| 21 #include "chrome/browser/content_settings/content_settings_utils.h" | 21 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 22 #include "chrome/browser/prefs/browser_prefs.h" | 22 #include "chrome/browser/prefs/browser_prefs.h" |
| 23 #include "chrome/browser/prefs/pref_service_mock_factory.h" | 23 #include "chrome/browser/prefs/pref_service_mock_factory.h" |
| 24 #include "chrome/browser/prefs/pref_service_syncable.h" | 24 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/content_settings_component.h" |
| 26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 28 #include "chrome/test/base/testing_pref_service_syncable.h" | 29 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 29 #include "chrome/test/base/testing_profile.h" | 30 #include "chrome/test/base/testing_profile.h" |
| 30 #include "components/pref_registry/pref_registry_syncable.h" | 31 #include "components/pref_registry/pref_registry_syncable.h" |
| 31 #include "content/public/test/test_browser_thread.h" | 32 #include "content/public/test/test_browser_thread.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 34 | 35 |
| 35 using ::testing::_; | 36 using ::testing::_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 PrefProvider* provider_; | 90 PrefProvider* provider_; |
| 90 PrefChangeRegistrar pref_change_registrar_; | 91 PrefChangeRegistrar pref_change_registrar_; |
| 91 bool notification_received_; | 92 bool notification_received_; |
| 92 DISALLOW_COPY_AND_ASSIGN(DeadlockCheckerObserver); | 93 DISALLOW_COPY_AND_ASSIGN(DeadlockCheckerObserver); |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 class PrefProviderTest : public testing::Test { | 96 class PrefProviderTest : public testing::Test { |
| 96 public: | 97 public: |
| 97 PrefProviderTest() : ui_thread_( | 98 PrefProviderTest() : ui_thread_( |
| 98 BrowserThread::UI, &message_loop_) { | 99 BrowserThread::UI, &message_loop_) { |
| 100 InitContentSettingsComponent(); |
| 99 } | 101 } |
| 100 | 102 |
| 101 protected: | 103 protected: |
| 102 base::MessageLoop message_loop_; | 104 base::MessageLoop message_loop_; |
| 103 content::TestBrowserThread ui_thread_; | 105 content::TestBrowserThread ui_thread_; |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 TEST_F(PrefProviderTest, Observer) { | 108 TEST_F(PrefProviderTest, Observer) { |
| 107 TestingProfile profile; | 109 TestingProfile profile; |
| 108 PrefProvider pref_content_settings_provider(profile.GetPrefs(), false); | 110 PrefProvider pref_content_settings_provider(profile.GetPrefs(), false); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 base::Time second = pref_content_settings_provider.GetLastUsage( | 474 base::Time second = pref_content_settings_provider.GetLastUsage( |
| 473 pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION); | 475 pattern, pattern, CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 474 | 476 |
| 475 base::TimeDelta delta = second - first; | 477 base::TimeDelta delta = second - first; |
| 476 EXPECT_EQ(delta.InSeconds(), 10); | 478 EXPECT_EQ(delta.InSeconds(), 10); |
| 477 | 479 |
| 478 pref_content_settings_provider.ShutdownOnUIThread(); | 480 pref_content_settings_provider.ShutdownOnUIThread(); |
| 479 } | 481 } |
| 480 | 482 |
| 481 } // namespace content_settings | 483 } // namespace content_settings |
| OLD | NEW |