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
3// found in the LICENSE file.
4
5#include "chrome/browser/chromeos/net/onc_utils.h"
6
7#include <string>
8
9#include "base/strings/string_number_conversions.h"
10#include "base/values.h"
11#include "chromeos/network/network_ui_data.h"
12#include "chromeos/network/onc/onc_test_utils.h"
13#include "google_apis/drive/test_util.h"
14#include "testing/gtest/include/gtest/gtest.h"
15
16namespace chromeos {
17namespace onc {
18
19TEST(ONCUtils, ProxySettingsToProxyConfig) {
20  scoped_ptr<base::Value> test_data =
21      google_apis::test_util::LoadJSONFile("chromeos/net/proxy_config.json");
22
23  base::ListValue* list_of_tests;
24  test_data->GetAsList(&list_of_tests);
25
26  int index = 0;
27  for (base::ListValue::iterator it = list_of_tests->begin();
28       it != list_of_tests->end(); ++it, ++index) {
29    SCOPED_TRACE("Test case #" + base::IntToString(index));
30
31    base::DictionaryValue* test_case;
32    (*it)->GetAsDictionary(&test_case);
33
34    base::DictionaryValue* onc_proxy_settings;
35    test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings);
36
37    base::DictionaryValue* expected_proxy_config;
38    test_case->GetDictionary("ProxyConfig", &expected_proxy_config);
39
40    scoped_ptr<base::DictionaryValue> actual_proxy_config =
41        ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings);
42    EXPECT_TRUE(test_utils::Equals(expected_proxy_config,
43                                   actual_proxy_config.get()));
44  }
45}
46
47}  // namespace onc
48}  // namespace chromeos
49