OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/shill_manager_client.h" | 10 #include "chromeos/dbus/shill_manager_client.h" |
11 #include "chromeos/network/geolocation_handler.h" | 11 #include "chromeos/network/geolocation_handler.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/cros_system_api/dbus/service_constants.h" | 13 #include "third_party/cros_system_api/dbus/service_constants.h" |
14 | 14 |
15 namespace chromeos { | 15 namespace chromeos { |
16 | 16 |
17 class GeolocationHandlerTest : public testing::Test { | 17 class GeolocationHandlerTest : public testing::Test { |
18 public: | 18 public: |
19 GeolocationHandlerTest() : manager_test_(NULL) { | 19 GeolocationHandlerTest() : manager_test_(NULL) { |
20 } | 20 } |
21 | 21 |
22 virtual ~GeolocationHandlerTest() { | 22 virtual ~GeolocationHandlerTest() { |
23 } | 23 } |
24 | 24 |
25 virtual void SetUp() OVERRIDE { | 25 virtual void SetUp() override { |
26 // Initialize DBusThreadManager with a stub implementation. | 26 // Initialize DBusThreadManager with a stub implementation. |
27 DBusThreadManager::Initialize(); | 27 DBusThreadManager::Initialize(); |
28 // Get the test interface for manager / device. | 28 // Get the test interface for manager / device. |
29 manager_test_ = | 29 manager_test_ = |
30 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); | 30 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); |
31 ASSERT_TRUE(manager_test_); | 31 ASSERT_TRUE(manager_test_); |
32 geolocation_handler_.reset(new GeolocationHandler()); | 32 geolocation_handler_.reset(new GeolocationHandler()); |
33 geolocation_handler_->Init(); | 33 geolocation_handler_->Init(); |
34 message_loop_.RunUntilIdle(); | 34 message_loop_.RunUntilIdle(); |
35 } | 35 } |
36 | 36 |
37 virtual void TearDown() OVERRIDE { | 37 virtual void TearDown() override { |
38 geolocation_handler_.reset(); | 38 geolocation_handler_.reset(); |
39 DBusThreadManager::Shutdown(); | 39 DBusThreadManager::Shutdown(); |
40 } | 40 } |
41 | 41 |
42 bool GetWifiAccessPoints() { | 42 bool GetWifiAccessPoints() { |
43 return geolocation_handler_->GetWifiAccessPoints( | 43 return geolocation_handler_->GetWifiAccessPoints( |
44 &wifi_access_points_, NULL); | 44 &wifi_access_points_, NULL); |
45 } | 45 } |
46 | 46 |
47 void AddAccessPoint(int idx) { | 47 void AddAccessPoint(int idx) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 EXPECT_FALSE(GetWifiAccessPoints()); | 103 EXPECT_FALSE(GetWifiAccessPoints()); |
104 message_loop_.RunUntilIdle(); | 104 message_loop_.RunUntilIdle(); |
105 // Second call should return true since we have an access point. | 105 // Second call should return true since we have an access point. |
106 EXPECT_TRUE(GetWifiAccessPoints()); | 106 EXPECT_TRUE(GetWifiAccessPoints()); |
107 ASSERT_EQ(3u, wifi_access_points_.size()); | 107 ASSERT_EQ(3u, wifi_access_points_.size()); |
108 EXPECT_EQ("02:00:00:00:00:00", wifi_access_points_[1].mac_address); | 108 EXPECT_EQ("02:00:00:00:00:00", wifi_access_points_[1].mac_address); |
109 EXPECT_EQ(3, wifi_access_points_[2].channel); | 109 EXPECT_EQ(3, wifi_access_points_[2].channel); |
110 } | 110 } |
111 | 111 |
112 } // namespace chromeos | 112 } // namespace chromeos |
OLD | NEW |