OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/chrome/browser/geolocation/omnibox_geolocation_local_state.h" | 5 #include "ios/chrome/browser/geolocation/omnibox_geolocation_local_state.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
11 #include "components/prefs/testing_pref_service.h" | 11 #include "components/prefs/testing_pref_service.h" |
12 #include "ios/chrome/browser/geolocation/location_manager.h" | 12 #include "ios/chrome/browser/geolocation/location_manager.h" |
13 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" | 13 #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" |
14 #include "ios/chrome/test/testing_application_context.h" | 14 #include "ios/chrome/test/testing_application_context.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/gtest_mac.h" | 16 #include "testing/gtest_mac.h" |
17 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
18 | 18 |
| 19 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 20 #error "This file requires ARC support." |
| 21 #endif |
| 22 |
19 namespace { | 23 namespace { |
20 | 24 |
21 class OmniboxGeolocationLocalStateTest : public PlatformTest { | 25 class OmniboxGeolocationLocalStateTest : public PlatformTest { |
22 protected: | 26 protected: |
23 OmniboxGeolocationLocalStateTest() { | 27 OmniboxGeolocationLocalStateTest() { |
24 location_manager_.reset([[LocationManager alloc] init]); | 28 location_manager_.reset([[LocationManager alloc] init]); |
25 local_state_.reset([[OmniboxGeolocationLocalState alloc] | 29 local_state_.reset([[OmniboxGeolocationLocalState alloc] |
26 initWithLocationManager:location_manager_]); | 30 initWithLocationManager:location_manager_]); |
27 } | 31 } |
28 | 32 |
29 IOSChromeScopedTestingLocalState scoped_local_state_; | 33 IOSChromeScopedTestingLocalState scoped_local_state_; |
30 base::scoped_nsobject<LocationManager> location_manager_; | 34 base::scoped_nsobject<LocationManager> location_manager_; |
31 base::scoped_nsobject<OmniboxGeolocationLocalState> local_state_; | 35 base::scoped_nsobject<OmniboxGeolocationLocalState> local_state_; |
32 }; | 36 }; |
33 | 37 |
34 TEST_F(OmniboxGeolocationLocalStateTest, LastAuthorizationAlertVersion) { | 38 TEST_F(OmniboxGeolocationLocalStateTest, LastAuthorizationAlertVersion) { |
35 EXPECT_TRUE([local_state_ lastAuthorizationAlertVersion].empty()); | 39 EXPECT_TRUE([local_state_ lastAuthorizationAlertVersion].empty()); |
36 | 40 |
37 std::string expectedVersion("fakeVersion"); | 41 std::string expectedVersion("fakeVersion"); |
38 [local_state_ setLastAuthorizationAlertVersion:expectedVersion]; | 42 [local_state_ setLastAuthorizationAlertVersion:expectedVersion]; |
39 EXPECT_EQ(expectedVersion, [local_state_ lastAuthorizationAlertVersion]); | 43 EXPECT_EQ(expectedVersion, [local_state_ lastAuthorizationAlertVersion]); |
40 } | 44 } |
41 | 45 |
42 } // namespace | 46 } // namespace |
OLD | NEW |