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

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

Issue 1779633002: Invoke createNetwork() callback with GUID, not service name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more trybot failures Created 4 years, 9 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 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/wifi_sync/wifi_config_delegate_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chromeos/network/managed_network_configuration_handler.h" 12 #include "chromeos/network/managed_network_configuration_handler.h"
13 #include "chromeos/network/network_handler_callbacks.h" 13 #include "chromeos/network/network_handler_callbacks.h"
14 #include "components/wifi_sync/wifi_credential.h" 14 #include "components/wifi_sync/wifi_credential.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace wifi_sync { 17 namespace wifi_sync {
18 18
19 namespace { 19 namespace {
20 const char kSsid[] = "fake-ssid"; 20 const char kSsid[] = "fake-ssid";
21 const char kSsidNonUtf8[] = "\xc0"; 21 const char kSsidNonUtf8[] = "\xc0";
22 const char kUserHash[] = "fake-user-hash"; 22 const char kUserHash[] = "fake-user-hash";
23 } 23 }
24 24
25 using chromeos::network_handler::DictionaryResultCallback; 25 using chromeos::network_handler::DictionaryResultCallback;
26 using chromeos::network_handler::ErrorCallback; 26 using chromeos::network_handler::ErrorCallback;
27 using chromeos::network_handler::StringResultCallback; 27 using chromeos::network_handler::ServiceResultCallback;
28 28
29 class FakeManagedNetworkConfigurationHandler 29 class FakeManagedNetworkConfigurationHandler
30 : public chromeos::ManagedNetworkConfigurationHandler { 30 : public chromeos::ManagedNetworkConfigurationHandler {
31 public: 31 public:
32 FakeManagedNetworkConfigurationHandler() 32 FakeManagedNetworkConfigurationHandler()
33 : create_configuration_called_(false) { 33 : create_configuration_called_(false) {
34 } 34 }
35 35
36 // ManagedNetworkConfigurationHandler implementation. 36 // ManagedNetworkConfigurationHandler implementation.
37 void AddObserver(chromeos::NetworkPolicyObserver* observer) override { 37 void AddObserver(chromeos::NetworkPolicyObserver* observer) override {
(...skipping 16 matching lines...) Expand all
54 const ErrorCallback& error_callback) override { 54 const ErrorCallback& error_callback) override {
55 NOTIMPLEMENTED(); 55 NOTIMPLEMENTED();
56 } 56 }
57 void SetProperties( 57 void SetProperties(
58 const std::string& service_path, 58 const std::string& service_path,
59 const base::DictionaryValue& user_settings, 59 const base::DictionaryValue& user_settings,
60 const base::Closure& callback, 60 const base::Closure& callback,
61 const ErrorCallback& error_callback) override { 61 const ErrorCallback& error_callback) override {
62 NOTIMPLEMENTED(); 62 NOTIMPLEMENTED();
63 } 63 }
64 void CreateConfiguration( 64 void CreateConfiguration(const std::string& userhash,
65 const std::string& userhash, 65 const base::DictionaryValue& properties,
66 const base::DictionaryValue& properties, 66 const ServiceResultCallback& callback,
67 const StringResultCallback& callback, 67 const ErrorCallback& error_callback) const override {
68 const ErrorCallback& error_callback) const override {
69 EXPECT_FALSE(create_configuration_called_); 68 EXPECT_FALSE(create_configuration_called_);
70 create_configuration_called_ = true; 69 create_configuration_called_ = true;
71 create_configuration_success_callback_ = callback; 70 create_configuration_success_callback_ = callback;
72 create_configuration_error_callback_ = error_callback; 71 create_configuration_error_callback_ = error_callback;
73 } 72 }
74 void RemoveConfiguration( 73 void RemoveConfiguration(
75 const std::string& service_path, 74 const std::string& service_path,
76 const base::Closure& callback, 75 const base::Closure& callback,
77 const ErrorCallback& error_callback) const override { 76 const ErrorCallback& error_callback) const override {
78 NOTIMPLEMENTED(); 77 NOTIMPLEMENTED();
(...skipping 29 matching lines...) Expand all
108 const base::DictionaryValue* FindPolicyByGuidAndProfile( 107 const base::DictionaryValue* FindPolicyByGuidAndProfile(
109 const std::string& guid, 108 const std::string& guid,
110 const std::string& profile_path) const override { 109 const std::string& profile_path) const override {
111 NOTIMPLEMENTED(); 110 NOTIMPLEMENTED();
112 return nullptr; 111 return nullptr;
113 } 112 }
114 113
115 bool create_configuration_called() const { 114 bool create_configuration_called() const {
116 return create_configuration_called_; 115 return create_configuration_called_;
117 } 116 }
118 const StringResultCallback& create_configuration_success_callback() const { 117 const ServiceResultCallback& create_configuration_success_callback() const {
119 return create_configuration_success_callback_; 118 return create_configuration_success_callback_;
120 } 119 }
121 const ErrorCallback& create_configuration_error_callback() const { 120 const ErrorCallback& create_configuration_error_callback() const {
122 return create_configuration_error_callback_; 121 return create_configuration_error_callback_;
123 } 122 }
124 123
125 private: 124 private:
126 // Whether or not CreateConfiguration has been called on this fake. 125 // Whether or not CreateConfiguration has been called on this fake.
127 mutable bool create_configuration_called_; 126 mutable bool create_configuration_called_;
128 // The last |callback| passed to CreateConfiguration. 127 // The last |callback| passed to CreateConfiguration.
129 mutable StringResultCallback create_configuration_success_callback_; 128 mutable ServiceResultCallback create_configuration_success_callback_;
130 // The last |error_callback| passed to CreateConfiguration. 129 // The last |error_callback| passed to CreateConfiguration.
131 mutable ErrorCallback create_configuration_error_callback_; 130 mutable ErrorCallback create_configuration_error_callback_;
132 }; 131 };
133 132
134 class WifiConfigDelegateChromeOsTest : public testing::Test { 133 class WifiConfigDelegateChromeOsTest : public testing::Test {
135 protected: 134 protected:
136 WifiConfigDelegateChromeOsTest() 135 WifiConfigDelegateChromeOsTest()
137 : fake_managed_network_configuration_handler_( 136 : fake_managed_network_configuration_handler_(
138 new FakeManagedNetworkConfigurationHandler()) { 137 new FakeManagedNetworkConfigurationHandler()) {
139 config_delegate_.reset( 138 config_delegate_.reset(
(...skipping 17 matching lines...) Expand all
157 security_class, 156 security_class,
158 passphrase); 157 passphrase);
159 CHECK(credential); 158 CHECK(credential);
160 return *credential; 159 return *credential;
161 } 160 }
162 161
163 // Runs the last |callback| passed to CreateConfiguration, unless 162 // Runs the last |callback| passed to CreateConfiguration, unless
164 // that |callback| is null. 163 // that |callback| is null.
165 void RunCreateConfigurationSuccessCallback() { 164 void RunCreateConfigurationSuccessCallback() {
166 const char new_service_path[] = "/service/0"; 165 const char new_service_path[] = "/service/0";
167 const StringResultCallback callback = 166 const ServiceResultCallback callback =
168 fake_managed_network_configuration_handler_ 167 fake_managed_network_configuration_handler_
169 ->create_configuration_success_callback(); 168 ->create_configuration_success_callback();
170 if (!callback.is_null()) 169 if (!callback.is_null())
171 callback.Run(new_service_path); 170 callback.Run(new_service_path, nullptr);
172 } 171 }
173 172
174 // Returns whether or not CreateConfiguration has been called 173 // Returns whether or not CreateConfiguration has been called
175 // on |fake_managed_network_configuration_handler_|. 174 // on |fake_managed_network_configuration_handler_|.
176 size_t create_configuration_called() const { 175 size_t create_configuration_called() const {
177 return fake_managed_network_configuration_handler_ 176 return fake_managed_network_configuration_handler_
178 ->create_configuration_called(); 177 ->create_configuration_called();
179 } 178 }
180 179
181 // Returns the last |error_callback| passed to the CreateConfiguration 180 // Returns the last |error_callback| passed to the CreateConfiguration
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 AddToLocalNetworks(MakeCredential(kSsid, SECURITY_CLASS_NONE, "")); 222 AddToLocalNetworks(MakeCredential(kSsid, SECURITY_CLASS_NONE, ""));
224 EXPECT_TRUE(create_configuration_called()); 223 EXPECT_TRUE(create_configuration_called());
225 if (!create_configuration_error_callback().is_null()) { 224 if (!create_configuration_error_callback().is_null()) {
226 create_configuration_error_callback().Run( 225 create_configuration_error_callback().Run(
227 "Config.CreateConfiguration Failed", 226 "Config.CreateConfiguration Failed",
228 make_scoped_ptr(new base::DictionaryValue())); 227 make_scoped_ptr(new base::DictionaryValue()));
229 } 228 }
230 } 229 }
231 230
232 } // namespace wifi_sync 231 } // namespace wifi_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698