OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/network/auto_connect_handler.h" | 5 #include "chromeos/network/auto_connect_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 base::DictionaryValue global_config; | 400 base::DictionaryValue global_config; |
401 global_config.SetBooleanWithoutPathExpansion( | 401 global_config.SetBooleanWithoutPathExpansion( |
402 ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, | 402 ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, |
403 true); | 403 true); |
404 | 404 |
405 // Applying the policy which restricts autoconnect should disconnect from the | 405 // Applying the policy which restricts autoconnect should disconnect from the |
406 // shared, unmanaged network. | 406 // shared, unmanaged network. |
407 // Because no best service is set, the fake implementation of | 407 // Because no best service is set, the fake implementation of |
408 // ConnectToBestServices will be a no-op. | 408 // ConnectToBestServices will be a no-op. |
409 SetupPolicy(kPolicy, global_config, false /* load as device policy */); | 409 SetupPolicy(kPolicy, global_config, false /* load as device policy */); |
| 410 |
| 411 // Should not trigger any change until user policy is loaded |
| 412 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); |
| 413 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); |
| 414 |
| 415 SetupPolicy(std::string(), base::DictionaryValue(), true); |
410 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi0")); | 416 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi0")); |
411 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); | 417 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); |
412 } | 418 } |
413 | 419 |
414 // After login a reconnect is triggered even if there is no managed network. | 420 // After login a reconnect is triggered even if there is no managed network. |
415 TEST_F(AutoConnectHandlerTest, ReconnectAfterLogin) { | 421 TEST_F(AutoConnectHandlerTest, ReconnectAfterLogin) { |
416 EXPECT_TRUE(Configure(kConfigUnmanagedSharedConnected)); | 422 EXPECT_TRUE(Configure(kConfigUnmanagedSharedConnected)); |
417 EXPECT_TRUE(Configure(kConfigManagedSharedConnectable)); | 423 EXPECT_TRUE(Configure(kConfigManagedSharedConnectable)); |
418 test_manager_client_->SetBestServiceToConnect("wifi1"); | 424 test_manager_client_->SetBestServiceToConnect("wifi1"); |
419 | 425 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 // Applying the user policy after login would usually trigger connecting to | 470 // Applying the user policy after login would usually trigger connecting to |
465 // the 'best' network. But the manual connect prevents this. | 471 // the 'best' network. But the manual connect prevents this. |
466 SetupPolicy(std::string(), // no network configs | 472 SetupPolicy(std::string(), // no network configs |
467 base::DictionaryValue(), // no global config | 473 base::DictionaryValue(), // no global config |
468 true); // load as user policy | 474 true); // load as user policy |
469 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); | 475 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); |
470 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); | 476 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); |
471 } | 477 } |
472 | 478 |
473 } // namespace chromeos | 479 } // namespace chromeos |
OLD | NEW |