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 "content/browser/browser_thread_impl.h" | 5 #include "content/browser/browser_thread_impl.h" |
6 #include "content/browser/geolocation/gps_location_provider_linux.h" | 6 #include "content/browser/geolocation/gps_location_provider_linux.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 class MockLibGps : public LibGps { | 13 class MockLibGps : public LibGps { |
14 public: | 14 public: |
15 MockLibGps(); | 15 MockLibGps(); |
16 ~MockLibGps(); | 16 virtual ~MockLibGps(); |
17 | 17 |
18 virtual bool GetPositionIfFixed(Geoposition* position) { | 18 virtual bool GetPositionIfFixed(Geoposition* position) OVERRIDE { |
19 CHECK(position); | 19 CHECK(position); |
20 ++get_position_calls_; | 20 ++get_position_calls_; |
21 *position = get_position_; | 21 *position = get_position_; |
22 return get_position_ret_; | 22 return get_position_ret_; |
23 } | 23 } |
24 | 24 |
25 static int gps_open_stub(const char*, const char*, struct gps_data_t*) { | 25 static int gps_open_stub(const char*, const char*, struct gps_data_t*) { |
26 CHECK(g_instance_); | 26 CHECK(g_instance_); |
27 g_instance_->gps_open_calls_++; | 27 g_instance_->gps_open_calls_++; |
28 return g_instance_->gps_open_ret_; | 28 return g_instance_->gps_open_ret_; |
(...skipping 15 matching lines...) Expand all Loading... |
44 int gps_open_ret_; | 44 int gps_open_ret_; |
45 int gps_read_calls_; | 45 int gps_read_calls_; |
46 int gps_read_ret_; | 46 int gps_read_ret_; |
47 Geoposition get_position_; | 47 Geoposition get_position_; |
48 static MockLibGps* g_instance_; | 48 static MockLibGps* g_instance_; |
49 }; | 49 }; |
50 | 50 |
51 class LocaionProviderListenerLoopQuitter | 51 class LocaionProviderListenerLoopQuitter |
52 : public LocationProviderBase::ListenerInterface { | 52 : public LocationProviderBase::ListenerInterface { |
53 // LocationProviderBase::ListenerInterface | 53 // LocationProviderBase::ListenerInterface |
54 virtual void LocationUpdateAvailable(LocationProviderBase* provider) { | 54 virtual void LocationUpdateAvailable( |
| 55 LocationProviderBase* provider) OVERRIDE { |
55 MessageLoop::current()->Quit(); | 56 MessageLoop::current()->Quit(); |
56 } | 57 } |
57 }; | 58 }; |
58 | 59 |
59 class GeolocationGpsProviderLinuxTests : public testing::Test { | 60 class GeolocationGpsProviderLinuxTests : public testing::Test { |
60 public: | 61 public: |
61 GeolocationGpsProviderLinuxTests(); | 62 GeolocationGpsProviderLinuxTests(); |
62 ~GeolocationGpsProviderLinuxTests(); | 63 virtual ~GeolocationGpsProviderLinuxTests(); |
63 | 64 |
64 static LibGps* NewMockLibGps() { | 65 static LibGps* NewMockLibGps() { |
65 return new MockLibGps(); | 66 return new MockLibGps(); |
66 } | 67 } |
67 static LibGps* NoLibGpsFactory() { | 68 static LibGps* NoLibGpsFactory() { |
68 return NULL; | 69 return NULL; |
69 } | 70 } |
70 | 71 |
71 protected: | 72 protected: |
72 MessageLoop message_loop_; | 73 MessageLoop message_loop_; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 EXPECT_TRUE(position.Validate()); | 203 EXPECT_TRUE(position.Validate()); |
203 // 3 gps_open() calls are expected (2 failures and 1 success) | 204 // 3 gps_open() calls are expected (2 failures and 1 success) |
204 EXPECT_EQ(1, MockLibGps::g_instance_->get_position_calls_); | 205 EXPECT_EQ(1, MockLibGps::g_instance_->get_position_calls_); |
205 EXPECT_EQ(3, MockLibGps::g_instance_->gps_open_calls_); | 206 EXPECT_EQ(3, MockLibGps::g_instance_->gps_open_calls_); |
206 EXPECT_EQ(1, MockLibGps::g_instance_->gps_read_calls_); | 207 EXPECT_EQ(1, MockLibGps::g_instance_->gps_read_calls_); |
207 } | 208 } |
208 | 209 |
209 #endif // #if defined(OS_CHROMEOS) | 210 #endif // #if defined(OS_CHROMEOS) |
210 | 211 |
211 } // namespace content | 212 } // namespace content |
OLD | NEW |