OLD | NEW |
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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "chrome/browser/content_settings/content_settings_details.h" | 6 #include "chrome/browser/content_settings/content_settings_details.h" |
7 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 7 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 9 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 10 #include "chrome/common/chrome_notification_types.h" |
10 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
11 #include "chrome/test/testing_profile.h" | 12 #include "chrome/test/testing_profile.h" |
12 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
13 #include "content/common/notification_registrar.h" | 14 #include "content/common/notification_registrar.h" |
14 #include "content/common/notification_service.h" | 15 #include "content/common/notification_service.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 using ::testing::_; | 19 using ::testing::_; |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 class MockGeolocationSettingsObserver : public NotificationObserver { | 23 class MockGeolocationSettingsObserver : public NotificationObserver { |
23 public: | 24 public: |
24 MockGeolocationSettingsObserver(); | 25 MockGeolocationSettingsObserver(); |
25 | 26 |
26 virtual void Observe(NotificationType type, | 27 virtual void Observe(int type, |
27 const NotificationSource& source, | 28 const NotificationSource& source, |
28 const NotificationDetails& details); | 29 const NotificationDetails& details); |
29 | 30 |
30 MOCK_METHOD2(OnContentSettingsChanged, | 31 MOCK_METHOD2(OnContentSettingsChanged, |
31 void(GeolocationContentSettingsMap*, | 32 void(GeolocationContentSettingsMap*, |
32 ContentSettingsType)); | 33 ContentSettingsType)); |
33 | 34 |
34 private: | 35 private: |
35 NotificationRegistrar registrar_; | 36 NotificationRegistrar registrar_; |
36 }; | 37 }; |
37 | 38 |
38 MockGeolocationSettingsObserver::MockGeolocationSettingsObserver() { | 39 MockGeolocationSettingsObserver::MockGeolocationSettingsObserver() { |
39 registrar_.Add(this, NotificationType::GEOLOCATION_SETTINGS_CHANGED, | 40 registrar_.Add(this, chrome::NOTIFICATION_GEOLOCATION_SETTINGS_CHANGED, |
40 NotificationService::AllSources()); | 41 NotificationService::AllSources()); |
41 } | 42 } |
42 | 43 |
43 void MockGeolocationSettingsObserver::Observe( | 44 void MockGeolocationSettingsObserver::Observe( |
44 NotificationType type, | 45 int type, |
45 const NotificationSource& source, | 46 const NotificationSource& source, |
46 const NotificationDetails& details) { | 47 const NotificationDetails& details) { |
47 GeolocationContentSettingsMap* map = | 48 GeolocationContentSettingsMap* map = |
48 Source<GeolocationContentSettingsMap>(source).ptr(); | 49 Source<GeolocationContentSettingsMap>(source).ptr(); |
49 ContentSettingsDetails* settings_details = | 50 ContentSettingsDetails* settings_details = |
50 Details<ContentSettingsDetails>(details).ptr(); | 51 Details<ContentSettingsDetails>(details).ptr(); |
51 OnContentSettingsChanged(map, | 52 OnContentSettingsChanged(map, |
52 settings_details->type()); | 53 settings_details->type()); |
53 // This checks that calling a Get function from an observer doesn't | 54 // This checks that calling a Get function from an observer doesn't |
54 // deadlock. | 55 // deadlock. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 PrefService* prefs = profile.GetPrefs(); | 309 PrefService* prefs = profile.GetPrefs(); |
309 EXPECT_CALL( | 310 EXPECT_CALL( |
310 observer, | 311 observer, |
311 OnContentSettingsChanged(map, CONTENT_SETTINGS_TYPE_DEFAULT)); | 312 OnContentSettingsChanged(map, CONTENT_SETTINGS_TYPE_DEFAULT)); |
312 prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, | 313 prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, |
313 CONTENT_SETTING_ALLOW); | 314 CONTENT_SETTING_ALLOW); |
314 EXPECT_EQ(CONTENT_SETTING_ALLOW, map->GetDefaultContentSetting()); | 315 EXPECT_EQ(CONTENT_SETTING_ALLOW, map->GetDefaultContentSetting()); |
315 } | 316 } |
316 | 317 |
317 } // namespace | 318 } // namespace |
OLD | NEW |