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

Side by Side Diff: components/sync_wifi/wifi_config_delegate_chromeos_unittest.cc

Issue 2463463004: [Sync] Rename wifi_sync to sync_wifi. (Closed)
Patch Set: Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/wifi_sync/wifi_config_delegate_chromeos.h" 5 #include "components/sync_wifi/wifi_config_delegate_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chromeos/network/managed_network_configuration_handler.h" 15 #include "chromeos/network/managed_network_configuration_handler.h"
16 #include "chromeos/network/network_handler_callbacks.h" 16 #include "chromeos/network/network_handler_callbacks.h"
17 #include "components/wifi_sync/wifi_credential.h" 17 #include "components/sync_wifi/wifi_credential.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace wifi_sync { 20 namespace sync_wifi {
21 21
22 namespace { 22 namespace {
23 const char kSsid[] = "fake-ssid"; 23 const char kSsid[] = "fake-ssid";
24 const char kSsidNonUtf8[] = "\xc0"; 24 const char kSsidNonUtf8[] = "\xc0";
25 const char kUserHash[] = "fake-user-hash"; 25 const char kUserHash[] = "fake-user-hash";
26 } 26 }
27 27
28 using chromeos::network_handler::DictionaryResultCallback; 28 using chromeos::network_handler::DictionaryResultCallback;
29 using chromeos::network_handler::ErrorCallback; 29 using chromeos::network_handler::ErrorCallback;
30 using chromeos::network_handler::ServiceResultCallback; 30 using chromeos::network_handler::ServiceResultCallback;
31 31
32 class FakeManagedNetworkConfigurationHandler 32 class FakeManagedNetworkConfigurationHandler
33 : public chromeos::ManagedNetworkConfigurationHandler { 33 : public chromeos::ManagedNetworkConfigurationHandler {
34 public: 34 public:
35 FakeManagedNetworkConfigurationHandler() 35 FakeManagedNetworkConfigurationHandler()
36 : create_configuration_called_(false) { 36 : create_configuration_called_(false) {}
37 }
38 37
39 // ManagedNetworkConfigurationHandler implementation. 38 // ManagedNetworkConfigurationHandler implementation.
40 void AddObserver(chromeos::NetworkPolicyObserver* observer) override { 39 void AddObserver(chromeos::NetworkPolicyObserver* observer) override {
41 NOTIMPLEMENTED(); 40 NOTIMPLEMENTED();
42 } 41 }
43 void RemoveObserver(chromeos::NetworkPolicyObserver* observer) override { 42 void RemoveObserver(chromeos::NetworkPolicyObserver* observer) override {
44 NOTIMPLEMENTED(); 43 NOTIMPLEMENTED();
45 } 44 }
46 void GetProperties( 45 void GetProperties(const std::string& userhash,
47 const std::string& userhash, 46 const std::string& service_path,
48 const std::string& service_path, 47 const DictionaryResultCallback& callback,
49 const DictionaryResultCallback& callback, 48 const ErrorCallback& error_callback) override {
50 const ErrorCallback& error_callback) override {
51 NOTIMPLEMENTED(); 49 NOTIMPLEMENTED();
52 } 50 }
53 void GetManagedProperties( 51 void GetManagedProperties(const std::string& userhash,
54 const std::string& userhash, 52 const std::string& service_path,
55 const std::string& service_path, 53 const DictionaryResultCallback& callback,
56 const DictionaryResultCallback& callback, 54 const ErrorCallback& error_callback) override {
57 const ErrorCallback& error_callback) override {
58 NOTIMPLEMENTED(); 55 NOTIMPLEMENTED();
59 } 56 }
60 void SetProperties( 57 void SetProperties(const std::string& service_path,
61 const std::string& service_path, 58 const base::DictionaryValue& user_settings,
62 const base::DictionaryValue& user_settings, 59 const base::Closure& callback,
63 const base::Closure& callback, 60 const ErrorCallback& error_callback) override {
64 const ErrorCallback& error_callback) override {
65 NOTIMPLEMENTED(); 61 NOTIMPLEMENTED();
66 } 62 }
67 void CreateConfiguration(const std::string& userhash, 63 void CreateConfiguration(const std::string& userhash,
68 const base::DictionaryValue& properties, 64 const base::DictionaryValue& properties,
69 const ServiceResultCallback& callback, 65 const ServiceResultCallback& callback,
70 const ErrorCallback& error_callback) const override { 66 const ErrorCallback& error_callback) const override {
71 EXPECT_FALSE(create_configuration_called_); 67 EXPECT_FALSE(create_configuration_called_);
72 create_configuration_called_ = true; 68 create_configuration_called_ = true;
73 create_configuration_success_callback_ = callback; 69 create_configuration_success_callback_ = callback;
74 create_configuration_error_callback_ = error_callback; 70 create_configuration_error_callback_ = error_callback;
75 } 71 }
76 void RemoveConfiguration( 72 void RemoveConfiguration(const std::string& service_path,
77 const std::string& service_path, 73 const base::Closure& callback,
78 const base::Closure& callback, 74 const ErrorCallback& error_callback) const override {
79 const ErrorCallback& error_callback) const override {
80 NOTIMPLEMENTED(); 75 NOTIMPLEMENTED();
81 } 76 }
82 void SetPolicy( 77 void SetPolicy(::onc::ONCSource onc_source,
83 ::onc::ONCSource onc_source, 78 const std::string& userhash,
84 const std::string& userhash, 79 const base::ListValue& network_configs_onc,
85 const base::ListValue& network_configs_onc, 80 const base::DictionaryValue& global_network_config) override {
86 const base::DictionaryValue& global_network_config) override {
87 NOTIMPLEMENTED(); 81 NOTIMPLEMENTED();
88 } 82 }
89 bool IsAnyPolicyApplicationRunning() const override { 83 bool IsAnyPolicyApplicationRunning() const override {
90 NOTIMPLEMENTED(); 84 NOTIMPLEMENTED();
91 return false; 85 return false;
92 } 86 }
93 const base::DictionaryValue* FindPolicyByGUID( 87 const base::DictionaryValue* FindPolicyByGUID(
94 const std::string userhash, 88 const std::string userhash,
95 const std::string& guid, 89 const std::string& guid,
96 ::onc::ONCSource* onc_source) const override { 90 ::onc::ONCSource* onc_source) const override {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // The last |callback| passed to CreateConfiguration. 124 // The last |callback| passed to CreateConfiguration.
131 mutable ServiceResultCallback create_configuration_success_callback_; 125 mutable ServiceResultCallback create_configuration_success_callback_;
132 // The last |error_callback| passed to CreateConfiguration. 126 // The last |error_callback| passed to CreateConfiguration.
133 mutable ErrorCallback create_configuration_error_callback_; 127 mutable ErrorCallback create_configuration_error_callback_;
134 }; 128 };
135 129
136 class WifiConfigDelegateChromeOsTest : public testing::Test { 130 class WifiConfigDelegateChromeOsTest : public testing::Test {
137 protected: 131 protected:
138 WifiConfigDelegateChromeOsTest() 132 WifiConfigDelegateChromeOsTest()
139 : fake_managed_network_configuration_handler_( 133 : fake_managed_network_configuration_handler_(
140 new FakeManagedNetworkConfigurationHandler()) { 134 new FakeManagedNetworkConfigurationHandler()) {
141 config_delegate_.reset( 135 config_delegate_.reset(new WifiConfigDelegateChromeOs(
142 new WifiConfigDelegateChromeOs( 136 kUserHash, fake_managed_network_configuration_handler_.get()));
143 kUserHash,
144 fake_managed_network_configuration_handler_.get()));
145 } 137 }
146 138
147 // Wrapper for WifiConfigDelegateChromeOs::AddToLocalNetworks. 139 // Wrapper for WifiConfigDelegateChromeOs::AddToLocalNetworks.
148 void AddToLocalNetworks(const WifiCredential& network_credential) { 140 void AddToLocalNetworks(const WifiCredential& network_credential) {
149 config_delegate_->AddToLocalNetworks(network_credential); 141 config_delegate_->AddToLocalNetworks(network_credential);
150 } 142 }
151 143
152 // Returns a new WifiCredential constructed from the given parameters. 144 // Returns a new WifiCredential constructed from the given parameters.
153 WifiCredential MakeCredential(const std::string& ssid, 145 WifiCredential MakeCredential(const std::string& ssid,
154 WifiSecurityClass security_class, 146 WifiSecurityClass security_class,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 AddToLocalNetworksCreateConfigurationFailure) { 213 AddToLocalNetworksCreateConfigurationFailure) {
222 AddToLocalNetworks(MakeCredential(kSsid, SECURITY_CLASS_NONE, "")); 214 AddToLocalNetworks(MakeCredential(kSsid, SECURITY_CLASS_NONE, ""));
223 EXPECT_TRUE(create_configuration_called()); 215 EXPECT_TRUE(create_configuration_called());
224 if (!create_configuration_error_callback().is_null()) { 216 if (!create_configuration_error_callback().is_null()) {
225 create_configuration_error_callback().Run( 217 create_configuration_error_callback().Run(
226 "Config.CreateConfiguration Failed", 218 "Config.CreateConfiguration Failed",
227 base::MakeUnique<base::DictionaryValue>()); 219 base::MakeUnique<base::DictionaryValue>());
228 } 220 }
229 } 221 }
230 222
231 } // namespace wifi_sync 223 } // namespace sync_wifi
OLDNEW
« no previous file with comments | « components/sync_wifi/wifi_config_delegate_chromeos.cc ('k') | components/sync_wifi/wifi_credential.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698