Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / options / network_property_ui_data_unittest.cc
blob5c6f6e564afdc66bd363207c5e2b60bbb698609d
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/options/network_property_ui_data.h"
7 #include "base/values.h"
8 #include "components/onc/onc_constants.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace chromeos {
13 class NetworkPropertyUIDataTest : public testing::Test {
14 protected:
15 NetworkPropertyUIDataTest() {}
16 ~NetworkPropertyUIDataTest() override {}
18 void CheckProperty(const NetworkPropertyUIData& property,
19 const base::Value* expected_default_value,
20 bool expected_managed,
21 bool expected_editable) {
22 if (expected_default_value) {
23 EXPECT_TRUE(base::Value::Equals(expected_default_value,
24 property.default_value()));
25 } else {
26 EXPECT_FALSE(property.default_value());
28 EXPECT_EQ(expected_managed, property.IsManaged());
29 EXPECT_EQ(expected_editable, property.IsEditable());
33 TEST_F(NetworkPropertyUIDataTest, PropertyInit) {
34 NetworkPropertyUIData empty_prop;
35 CheckProperty(empty_prop, NULL, false, true);
37 NetworkPropertyUIData null_prop(onc::ONC_SOURCE_NONE);
38 CheckProperty(null_prop, NULL, false, true);
41 TEST_F(NetworkPropertyUIDataTest, ParseOncProperty) {
42 base::DictionaryValue onc;
44 base::StringValue val_a("a");
45 base::StringValue val_b("b");
46 base::StringValue val_a_a("a_a");
47 base::StringValue val_a_b("a_b");
49 onc.Set("a", val_a.DeepCopy());
50 onc.Set("b", val_b.DeepCopy());
51 onc.Set("a.a", val_a_a.DeepCopy());
52 onc.Set("a.b", val_a_b.DeepCopy());
53 base::ListValue recommended;
54 recommended.AppendString("b");
55 recommended.AppendString("c");
56 recommended.AppendString("a.a");
57 onc.Set("Recommended", recommended.DeepCopy());
58 onc.Set("a.Recommended", recommended.DeepCopy());
60 NetworkPropertyUIData prop;
62 prop.ParseOncProperty(onc::ONC_SOURCE_NONE, &onc, "a");
63 CheckProperty(prop, NULL, false, true);
65 onc::ONCSource source = onc::ONC_SOURCE_USER_IMPORT;
67 prop.ParseOncProperty(source, &onc, "a");
68 CheckProperty(prop, NULL, false, true);
70 prop.ParseOncProperty(source, &onc, "a.b");
71 CheckProperty(prop, NULL, false, true);
73 prop.ParseOncProperty(source, &onc, "c");
74 CheckProperty(prop, NULL, false, true);
76 source = onc::ONC_SOURCE_USER_POLICY;
78 prop.ParseOncProperty(source, &onc, "a");
79 CheckProperty(prop, NULL, true, false);
81 prop.ParseOncProperty(source, &onc, "b");
82 CheckProperty(prop, &val_b, false, true);
84 prop.ParseOncProperty(source, &onc, "c");
85 CheckProperty(prop, NULL, false, true);
87 prop.ParseOncProperty(source, &onc, "d");
88 CheckProperty(prop, NULL, true, false);
90 prop.ParseOncProperty(source, &onc, "a.a");
91 CheckProperty(prop, NULL, true, false);
93 prop.ParseOncProperty(source, &onc, "a.b");
94 CheckProperty(prop, &val_a_b, false, true);
96 prop.ParseOncProperty(source, &onc, "a.c");
97 CheckProperty(prop, NULL, false, true);
99 prop.ParseOncProperty(source, &onc, "a.d");
100 CheckProperty(prop, NULL, true, false);
102 prop.ParseOncProperty(source, NULL, "a.e");
103 CheckProperty(prop, NULL, true, false);
106 } // namespace chromeos