Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: device/geolocation/wifi_data_provider_linux_unittest.cc

Issue 2849613002: Use ScopedTaskEnvironment instead of MessageLoopForUI in device tests. (Closed)
Patch Set: self-review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "device/geolocation/wifi_data_provider_linux.h" 5 #include "device/geolocation/wifi_data_provider_linux.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/test/scoped_task_environment.h"
15 #include "dbus/message.h" 15 #include "dbus/message.h"
16 #include "dbus/mock_bus.h" 16 #include "dbus/mock_bus.h"
17 #include "dbus/mock_object_proxy.h" 17 #include "dbus/mock_object_proxy.h"
18 #include "dbus/object_path.h" 18 #include "dbus/object_path.h"
19 #include "dbus/object_proxy.h" 19 #include "dbus/object_proxy.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 using ::testing::_; 23 using ::testing::_;
24 using ::testing::Invoke; 24 using ::testing::Invoke;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // ShutdownAndBlock() should be called. 90 // ShutdownAndBlock() should be called.
91 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return()); 91 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return());
92 92
93 // Create the wlan API with the mock bus object injected. 93 // Create the wlan API with the mock bus object injected.
94 wifi_provider_linux_ = new WifiDataProviderLinux; 94 wifi_provider_linux_ = new WifiDataProviderLinux;
95 wlan_api_ = wifi_provider_linux_->CreateWlanApiForTesting(mock_bus_.get()); 95 wlan_api_ = wifi_provider_linux_->CreateWlanApiForTesting(mock_bus_.get());
96 ASSERT_TRUE(wlan_api_); 96 ASSERT_TRUE(wlan_api_);
97 } 97 }
98 98
99 protected: 99 protected:
100 GeolocationWifiDataProviderLinuxTest()
101 : scoped_task_environment_(
102 base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
103
100 // WifiDataProvider requires a task runner to be present. The |message_loop_| 104 // WifiDataProvider requires a task runner to be present. The |message_loop_|
101 // is defined here, as it should outlive |wifi_provider_linux_|. 105 // is defined here, as it should outlive |wifi_provider_linux_|.
102 base::MessageLoopForUI message_loop_; 106 base::test::ScopedTaskEnvironment scoped_task_environment_;
103 scoped_refptr<dbus::MockBus> mock_bus_; 107 scoped_refptr<dbus::MockBus> mock_bus_;
104 scoped_refptr<dbus::MockObjectProxy> mock_network_manager_proxy_; 108 scoped_refptr<dbus::MockObjectProxy> mock_network_manager_proxy_;
105 scoped_refptr<dbus::MockObjectProxy> mock_access_point_proxy_; 109 scoped_refptr<dbus::MockObjectProxy> mock_access_point_proxy_;
106 scoped_refptr<dbus::MockObjectProxy> mock_device_proxy_; 110 scoped_refptr<dbus::MockObjectProxy> mock_device_proxy_;
107 scoped_refptr<WifiDataProviderLinux> wifi_provider_linux_; 111 scoped_refptr<WifiDataProviderLinux> wifi_provider_linux_;
108 std::unique_ptr<WifiDataProviderCommon::WlanApiInterface> wlan_api_; 112 std::unique_ptr<WifiDataProviderCommon::WlanApiInterface> wlan_api_;
109 113
110 private: 114 private:
111 // Creates a response for |mock_network_manager_proxy_|. 115 // Creates a response for |mock_network_manager_proxy_|.
112 dbus::Response* CreateNetworkManagerProxyResponse( 116 dbus::Response* CreateNetworkManagerProxyResponse(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // Check the contents of the access point data. 222 // Check the contents of the access point data.
219 // The expected values come from CreateAccessPointProxyResponse() above. 223 // The expected values come from CreateAccessPointProxyResponse() above.
220 EXPECT_EQ("test", base::UTF16ToUTF8(access_point_data.ssid)); 224 EXPECT_EQ("test", base::UTF16ToUTF8(access_point_data.ssid));
221 EXPECT_EQ("00-11-22-33-44-55", 225 EXPECT_EQ("00-11-22-33-44-55",
222 base::UTF16ToUTF8(access_point_data.mac_address)); 226 base::UTF16ToUTF8(access_point_data.mac_address));
223 EXPECT_EQ(-50, access_point_data.radio_signal_strength); 227 EXPECT_EQ(-50, access_point_data.radio_signal_strength);
224 EXPECT_EQ(4, access_point_data.channel); 228 EXPECT_EQ(4, access_point_data.channel);
225 } 229 }
226 230
227 } // namespace device 231 } // namespace device
OLDNEW
« no previous file with comments | « device/geolocation/wifi_data_provider_common_unittest.cc ('k') | device/u2f/u2f_register_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698