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 "content/browser/browser_thread_impl.h" |
5 #include "content/browser/geolocation/gps_location_provider_linux.h" | 6 #include "content/browser/geolocation/gps_location_provider_linux.h" |
6 #include "content/browser/geolocation/libgps_wrapper_linux.h" | 7 #include "content/browser/geolocation/libgps_wrapper_linux.h" |
7 #include "content/test/test_browser_thread.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
| 10 using content::BrowserThreadImpl; |
| 11 |
10 struct gps_data_t { | 12 struct gps_data_t { |
11 }; | 13 }; |
12 | 14 |
13 namespace { | 15 namespace { |
14 class MockLibGps : public LibGps { | 16 class MockLibGps : public LibGps { |
15 public: | 17 public: |
16 MockLibGps(); | 18 MockLibGps(); |
17 ~MockLibGps(); | 19 ~MockLibGps(); |
18 | 20 |
19 virtual bool StartStreaming() { | 21 virtual bool StartStreaming() { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 61 |
60 static LibGps* NewMockLibGps() { | 62 static LibGps* NewMockLibGps() { |
61 return new MockLibGps; | 63 return new MockLibGps; |
62 } | 64 } |
63 static LibGps* NoLibGpsFactory() { | 65 static LibGps* NoLibGpsFactory() { |
64 return NULL; | 66 return NULL; |
65 } | 67 } |
66 | 68 |
67 protected: | 69 protected: |
68 MessageLoop message_loop_; | 70 MessageLoop message_loop_; |
69 content::TestBrowserThread ui_thread_; | 71 BrowserThreadImpl ui_thread_; |
70 LocaionProviderListenerLoopQuitter location_listener_; | 72 LocaionProviderListenerLoopQuitter location_listener_; |
71 scoped_ptr<GpsLocationProviderLinux> provider_; | 73 scoped_ptr<GpsLocationProviderLinux> provider_; |
72 }; | 74 }; |
73 | 75 |
74 gps_data_t* gps_open_stub(const char*, const char*) { | 76 gps_data_t* gps_open_stub(const char*, const char*) { |
75 // Need to return a non-NULL value here to indicate success, however we don't | 77 // Need to return a non-NULL value here to indicate success, however we don't |
76 // need (or want) a valid pointer as it should never be dereferenced. | 78 // need (or want) a valid pointer as it should never be dereferenced. |
77 return static_cast<gps_data_t*>(NULL) + 1; | 79 return static_cast<gps_data_t*>(NULL) + 1; |
78 } | 80 } |
79 int gps_close_stub(gps_data_t*) { | 81 int gps_close_stub(gps_data_t*) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 EXPECT_EQ(2, MockLibGps::g_instance_->get_position_calls_); | 182 EXPECT_EQ(2, MockLibGps::g_instance_->get_position_calls_); |
181 CheckValidPosition(MockLibGps::g_instance_->get_position_, position); | 183 CheckValidPosition(MockLibGps::g_instance_->get_position_, position); |
182 } | 184 } |
183 | 185 |
184 // TODO(joth): Add a test for LibGps::Start() returning false (i.e. gpsd not | 186 // TODO(joth): Add a test for LibGps::Start() returning false (i.e. gpsd not |
185 // running). Need to work around the 10s reconnect delay (either by injecting | 187 // running). Need to work around the 10s reconnect delay (either by injecting |
186 // a shorter retry interval, or adapt MessageLoop / Time::Now to be more test | 188 // a shorter retry interval, or adapt MessageLoop / Time::Now to be more test |
187 // friendly). | 189 // friendly). |
188 | 190 |
189 } // namespace | 191 } // namespace |
OLD | NEW |