| 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 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const Geoposition& actual) { | 79 const Geoposition& actual) { |
| 80 EXPECT_TRUE(actual.Validate()); | 80 EXPECT_TRUE(actual.Validate()); |
| 81 EXPECT_DOUBLE_EQ(expected.latitude, actual.latitude); | 81 EXPECT_DOUBLE_EQ(expected.latitude, actual.latitude); |
| 82 EXPECT_DOUBLE_EQ(expected.longitude, actual.longitude); | 82 EXPECT_DOUBLE_EQ(expected.longitude, actual.longitude); |
| 83 EXPECT_DOUBLE_EQ(expected.accuracy, actual.accuracy); | 83 EXPECT_DOUBLE_EQ(expected.accuracy, actual.accuracy); |
| 84 } | 84 } |
| 85 | 85 |
| 86 MockLibGps* MockLibGps::g_instance_ = NULL; | 86 MockLibGps* MockLibGps::g_instance_ = NULL; |
| 87 | 87 |
| 88 MockLibGps::MockLibGps() | 88 MockLibGps::MockLibGps() |
| 89 : LibGps(NULL, gps_open_stub, gps_close_stub, gps_read_stub), | 89 : get_position_calls_(0), |
| 90 get_position_calls_(0), | |
| 91 get_position_ret_(true), | 90 get_position_ret_(true), |
| 92 gps_open_calls_(0), | 91 gps_open_calls_(0), |
| 93 gps_open_ret_(0), | 92 gps_open_ret_(0), |
| 94 gps_read_calls_(0), | 93 gps_read_calls_(0), |
| 95 gps_read_ret_(0) { | 94 gps_read_ret_(0) { |
| 96 get_position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | 95 get_position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; |
| 97 EXPECT_FALSE(g_instance_); | 96 EXPECT_FALSE(g_instance_); |
| 98 g_instance_ = this; | 97 g_instance_ = this; |
| 98 #if defined(USE_LIBGPS) |
| 99 libgps_loader_.gps_open = gps_open_stub; |
| 100 libgps_loader_.gps_close = gps_close_stub; |
| 101 libgps_loader_.gps_read = gps_read_stub; |
| 102 #endif // defined(USE_LIBGPS) |
| 99 } | 103 } |
| 100 | 104 |
| 101 MockLibGps::~MockLibGps() { | 105 MockLibGps::~MockLibGps() { |
| 102 EXPECT_EQ(this, g_instance_); | 106 EXPECT_EQ(this, g_instance_); |
| 103 g_instance_ = NULL; | 107 g_instance_ = NULL; |
| 104 } | 108 } |
| 105 | 109 |
| 106 GeolocationGpsProviderLinuxTests::GeolocationGpsProviderLinuxTests() | 110 GeolocationGpsProviderLinuxTests::GeolocationGpsProviderLinuxTests() |
| 107 : ui_thread_(BrowserThread::IO, &message_loop_), | 111 : ui_thread_(BrowserThread::IO, &message_loop_), |
| 108 provider_(new GpsLocationProviderLinux(NewMockLibGps)) { | 112 provider_(new GpsLocationProviderLinux(NewMockLibGps)) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 EXPECT_TRUE(position.Validate()); | 202 EXPECT_TRUE(position.Validate()); |
| 199 // 3 gps_open() calls are expected (2 failures and 1 success) | 203 // 3 gps_open() calls are expected (2 failures and 1 success) |
| 200 EXPECT_EQ(1, MockLibGps::g_instance_->get_position_calls_); | 204 EXPECT_EQ(1, MockLibGps::g_instance_->get_position_calls_); |
| 201 EXPECT_EQ(3, MockLibGps::g_instance_->gps_open_calls_); | 205 EXPECT_EQ(3, MockLibGps::g_instance_->gps_open_calls_); |
| 202 EXPECT_EQ(1, MockLibGps::g_instance_->gps_read_calls_); | 206 EXPECT_EQ(1, MockLibGps::g_instance_->gps_read_calls_); |
| 203 } | 207 } |
| 204 | 208 |
| 205 #endif // #if defined(OS_CHROMEOS) | 209 #endif // #if defined(OS_CHROMEOS) |
| 206 | 210 |
| 207 } // namespace content | 211 } // namespace content |
| OLD | NEW |