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

Side by Side Diff: chrome/browser/policy/network_configuration_updater_unittest.cc

Issue 8804020: Set onc_source UI data parameter when importing ONC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/policy/network_configuration_updater.h" 5 #include "chrome/browser/policy/network_configuration_updater.h"
6 6
7 #include "chrome/browser/chromeos/cros/mock_network_library.h" 7 #include "chrome/browser/chromeos/cros/mock_network_library.h"
8 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 8 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 using testing::Mock; 12 using testing::Mock;
13 using testing::Return; 13 using testing::Return;
14 using testing::_; 14 using testing::_;
15 15
16 namespace policy { 16 namespace policy {
17 17
18 static const char kFakeONC[] = "{ \"GUID\": \"1234\" }"; 18 static const char kFakeONC[] = "{ \"GUID\": \"1234\" }";
19 19
20 class NetworkConfigurationUpdaterTest 20 class NetworkConfigurationUpdaterTest
21 : public testing::TestWithParam<ConfigurationPolicyType> { 21 : public testing::TestWithParam<ConfigurationPolicyType> {
22 protected: 22 protected:
23 chromeos::MockNetworkLibrary network_library_; 23 chromeos::MockNetworkLibrary network_library_;
24 MockConfigurationPolicyProvider provider_; 24 MockConfigurationPolicyProvider provider_;
25 }; 25 };
26 26
27 TEST_P(NetworkConfigurationUpdaterTest, InitialUpdate) { 27 TEST_P(NetworkConfigurationUpdaterTest, InitialUpdate) {
28 provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC)); 28 provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
29 29
30 EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, "", _)) 30 EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, "", _, _))
31 .WillRepeatedly(Return(true)); 31 .WillRepeatedly(Return(true));
32 32
33 NetworkConfigurationUpdater updater(&provider_, &network_library_); 33 NetworkConfigurationUpdater updater(&provider_, &network_library_);
34 Mock::VerifyAndClearExpectations(&network_library_); 34 Mock::VerifyAndClearExpectations(&network_library_);
35 } 35 }
36 36
37 TEST_P(NetworkConfigurationUpdaterTest, PolicyChange) { 37 TEST_P(NetworkConfigurationUpdaterTest, PolicyChange) {
38 NetworkConfigurationUpdater updater(&provider_, &network_library_); 38 NetworkConfigurationUpdater updater(&provider_, &network_library_);
39 39
40 // We should update if policy changes. 40 // We should update if policy changes.
41 EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, "", _)) 41 EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, "", _, _))
42 .WillOnce(Return(true)); 42 .WillOnce(Return(true));
43 provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC)); 43 provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
44 provider_.NotifyPolicyUpdated(); 44 provider_.NotifyPolicyUpdated();
45 Mock::VerifyAndClearExpectations(&network_library_); 45 Mock::VerifyAndClearExpectations(&network_library_);
46 46
47 // No update if the set the same value again. 47 // No update if the set the same value again.
48 EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, "", _)) 48 EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, "", _, _))
49 .Times(0); 49 .Times(0);
50 provider_.NotifyPolicyUpdated(); 50 provider_.NotifyPolicyUpdated();
51 Mock::VerifyAndClearExpectations(&network_library_); 51 Mock::VerifyAndClearExpectations(&network_library_);
52 52
53 // Another update is expected if the policy goes away. 53 // Another update is expected if the policy goes away.
54 EXPECT_CALL(network_library_, LoadOncNetworks("", "", _)) 54 EXPECT_CALL(network_library_, LoadOncNetworks("", "", _, _))
55 .WillOnce(Return(true)); 55 .WillOnce(Return(true));
56 provider_.RemovePolicy(GetParam()); 56 provider_.RemovePolicy(GetParam());
57 provider_.NotifyPolicyUpdated(); 57 provider_.NotifyPolicyUpdated();
58 Mock::VerifyAndClearExpectations(&network_library_); 58 Mock::VerifyAndClearExpectations(&network_library_);
59 } 59 }
60 60
61 INSTANTIATE_TEST_CASE_P( 61 INSTANTIATE_TEST_CASE_P(
62 NetworkConfigurationUpdaterTestInstance, 62 NetworkConfigurationUpdaterTestInstance,
63 NetworkConfigurationUpdaterTest, 63 NetworkConfigurationUpdaterTest,
64 testing::Values(kPolicyDeviceOpenNetworkConfiguration, 64 testing::Values(kPolicyDeviceOpenNetworkConfiguration,
65 kPolicyOpenNetworkConfiguration)); 65 kPolicyOpenNetworkConfiguration));
66 66
67 } // namespace policy 67 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/network_configuration_updater.cc ('k') | chrome/browser/ui/webui/net_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698