OLD | NEW |
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 "chromeos/network/onc/onc_merger.h" | 5 #include "chromeos/network/onc/onc_merger.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 namespace merger { | 48 namespace merger { |
49 | 49 |
50 class ONCMergerTest : public testing::Test { | 50 class ONCMergerTest : public testing::Test { |
51 public: | 51 public: |
52 scoped_ptr<const base::DictionaryValue> user_; | 52 scoped_ptr<const base::DictionaryValue> user_; |
53 scoped_ptr<const base::DictionaryValue> policy_; | 53 scoped_ptr<const base::DictionaryValue> policy_; |
54 scoped_ptr<const base::DictionaryValue> policy_without_recommended_; | 54 scoped_ptr<const base::DictionaryValue> policy_without_recommended_; |
55 scoped_ptr<const base::DictionaryValue> device_policy_; | 55 scoped_ptr<const base::DictionaryValue> device_policy_; |
| 56 scoped_ptr<const base::DictionaryValue> active_; |
56 | 57 |
57 virtual void SetUp() { | 58 virtual void SetUp() { |
58 policy_ = test_utils::ReadTestDictionary("managed_vpn.onc"); | 59 policy_ = test_utils::ReadTestDictionary("managed_vpn.onc"); |
59 policy_without_recommended_ = | 60 policy_without_recommended_ = |
60 test_utils::ReadTestDictionary("managed_vpn_without_recommended.onc"); | 61 test_utils::ReadTestDictionary("managed_vpn_without_recommended.onc"); |
61 user_ = test_utils::ReadTestDictionary("user.onc"); | 62 user_ = test_utils::ReadTestDictionary("user.onc"); |
62 device_policy_ = test_utils::ReadTestDictionary("device_policy.onc"); | 63 device_policy_ = test_utils::ReadTestDictionary("device_policy.onc"); |
| 64 active_ = test_utils::ReadTestDictionary("vpn_active_settings.onc"); |
63 } | 65 } |
64 }; | 66 }; |
65 | 67 |
66 TEST_F(ONCMergerTest, MandatoryValueOverwritesUserValue) { | 68 TEST_F(ONCMergerTest, MandatoryValueOverwritesUserValue) { |
67 scoped_ptr<base::DictionaryValue> merged(MergeSettingsAndPoliciesToEffective( | 69 scoped_ptr<base::DictionaryValue> merged(MergeSettingsAndPoliciesToEffective( |
68 policy_.get(), NULL, user_.get(), NULL)); | 70 policy_.get(), NULL, user_.get(), NULL)); |
69 EXPECT_TRUE(HaveSameValueAt(*merged, *policy_, "Type")); | 71 EXPECT_TRUE(HaveSameValueAt(*merged, *policy_, "Type")); |
70 EXPECT_TRUE(HaveSameValueAt(*merged, *policy_, "IPConfigs")); | 72 EXPECT_TRUE(HaveSameValueAt(*merged, *policy_, "IPConfigs")); |
71 } | 73 } |
72 | 74 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 policy_.get(), device_policy_.get(), user_.get(), NULL)); | 143 policy_.get(), device_policy_.get(), user_.get(), NULL)); |
142 EXPECT_TRUE(HaveSameValueAt(*merged, *device_policy_, | 144 EXPECT_TRUE(HaveSameValueAt(*merged, *device_policy_, |
143 "VPN.OpenVPN.Username")); | 145 "VPN.OpenVPN.Username")); |
144 } | 146 } |
145 | 147 |
146 TEST_F(ONCMergerTest, MergeToAugmented) { | 148 TEST_F(ONCMergerTest, MergeToAugmented) { |
147 scoped_ptr<base::DictionaryValue> expected_augmented = | 149 scoped_ptr<base::DictionaryValue> expected_augmented = |
148 test_utils::ReadTestDictionary("augmented_merge.json"); | 150 test_utils::ReadTestDictionary("augmented_merge.json"); |
149 scoped_ptr<base::DictionaryValue> merged(MergeSettingsAndPoliciesToAugmented( | 151 scoped_ptr<base::DictionaryValue> merged(MergeSettingsAndPoliciesToAugmented( |
150 kNetworkConfigurationSignature, policy_.get(), device_policy_.get(), | 152 kNetworkConfigurationSignature, policy_.get(), device_policy_.get(), |
151 user_.get(), NULL, NULL)); | 153 user_.get(), NULL, active_.get())); |
152 EXPECT_TRUE(test_utils::Equals(expected_augmented.get(), merged.get())); | 154 EXPECT_TRUE(test_utils::Equals(expected_augmented.get(), merged.get())); |
153 } | 155 } |
154 | 156 |
155 } // namespace merger | 157 } // namespace merger |
156 } // namespace onc | 158 } // namespace onc |
157 } // namespace chromeos | 159 } // namespace chromeos |
OLD | NEW |