OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "extensions/browser/api/system_network/system_network_api.h" | 7 #include "extensions/browser/api/system_network/system_network_api.h" |
8 #include "extensions/browser/api_test_utils.h" | 8 #include "extensions/browser/api_test_utils.h" |
9 #include "extensions/common/test_util.h" | 9 #include "extensions/common/test_util.h" |
10 #include "extensions/shell/test/shell_apitest.h" | 10 #include "extensions/shell/test/shell_apitest.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult( | 37 std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult( |
38 socket_function.get(), "[]", browser_context())); | 38 socket_function.get(), "[]", browser_context())); |
39 ASSERT_EQ(base::Value::TYPE_LIST, result->GetType()); | 39 ASSERT_EQ(base::Value::TYPE_LIST, result->GetType()); |
40 | 40 |
41 // All we can confirm is that we have at least one address, but not what it | 41 // All we can confirm is that we have at least one address, but not what it |
42 // is. | 42 // is. |
43 base::ListValue* value = static_cast<base::ListValue*>(result.get()); | 43 base::ListValue* value = static_cast<base::ListValue*>(result.get()); |
44 ASSERT_TRUE(value->GetSize() > 0); | 44 ASSERT_TRUE(value->GetSize() > 0); |
45 | 45 |
46 for (base::ListValue::const_iterator it = value->begin(); it != value->end(); | 46 for (const auto& network_interface_value : *value) { |
47 ++it) { | |
48 base::Value* network_interface_value = *it; | |
49 | |
50 NetworkInterface network_interface; | 47 NetworkInterface network_interface; |
51 ASSERT_TRUE(NetworkInterface::Populate(*network_interface_value, | 48 ASSERT_TRUE(NetworkInterface::Populate(*network_interface_value, |
52 &network_interface)); | 49 &network_interface)); |
53 | 50 |
54 LOG(INFO) << "Network interface: address=" << network_interface.address | 51 LOG(INFO) << "Network interface: address=" << network_interface.address |
55 << ", name=" << network_interface.name | 52 << ", name=" << network_interface.name |
56 << ", prefix length=" << network_interface.prefix_length; | 53 << ", prefix length=" << network_interface.prefix_length; |
57 ASSERT_NE(std::string(), network_interface.address); | 54 ASSERT_NE(std::string(), network_interface.address); |
58 ASSERT_NE(std::string(), network_interface.name); | 55 ASSERT_NE(std::string(), network_interface.name); |
59 ASSERT_LE(0, network_interface.prefix_length); | 56 ASSERT_LE(0, network_interface.prefix_length); |
60 } | 57 } |
61 } | 58 } |
OLD | NEW |