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

Side by Side Diff: net/base/net_util_unittest.cc

Issue 112963005: Update uses of UTF conversions in courgette/, device/, extensions/, google_apis/, gpu/, ipc/, media… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 months 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
« no previous file with comments | « net/base/net_util.cc ('k') | net/base/net_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 #include <iphlpapi.h> 26 #include <iphlpapi.h>
27 #include <objbase.h> 27 #include <objbase.h>
28 #include "base/win/windows_version.h" 28 #include "base/win/windows_version.h"
29 #elif !defined(OS_ANDROID) 29 #elif !defined(OS_ANDROID)
30 #include <net/if.h> 30 #include <net/if.h>
31 #endif // OS_WIN 31 #endif // OS_WIN
32 32
33 using base::ASCIIToUTF16;
34 using base::WideToUTF16;
35
33 namespace net { 36 namespace net {
34 37
35 namespace { 38 namespace {
36 39
37 static const size_t kNpos = base::string16::npos; 40 static const size_t kNpos = base::string16::npos;
38 41
39 struct FileCase { 42 struct FileCase {
40 const wchar_t* file; 43 const wchar_t* file;
41 const char* url; 44 const char* url;
42 }; 45 };
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 std::string out; 489 std::string out;
487 for (size_t i = 0; i < v.size(); ++i) { 490 for (size_t i = 0; i < v.size(); ++i) {
488 if (i != 0) 491 if (i != 0)
489 out.append(","); 492 out.append(",");
490 out.append(base::IntToString(static_cast<int>(v[i]))); 493 out.append(base::IntToString(static_cast<int>(v[i])));
491 } 494 }
492 return out; 495 return out;
493 } 496 }
494 497
495 void RunGenerateFileNameTestCase(const GenerateFilenameCase* test_case) { 498 void RunGenerateFileNameTestCase(const GenerateFilenameCase* test_case) {
496 std::string default_filename(WideToUTF8(test_case->default_filename)); 499 std::string default_filename(base::WideToUTF8(test_case->default_filename));
497 base::FilePath file_path = GenerateFileName( 500 base::FilePath file_path = GenerateFileName(
498 GURL(test_case->url), test_case->content_disp_header, 501 GURL(test_case->url), test_case->content_disp_header,
499 test_case->referrer_charset, test_case->suggested_filename, 502 test_case->referrer_charset, test_case->suggested_filename,
500 test_case->mime_type, default_filename); 503 test_case->mime_type, default_filename);
501 EXPECT_EQ(test_case->expected_filename, 504 EXPECT_EQ(test_case->expected_filename,
502 file_util::FilePathAsWString(file_path)) 505 file_util::FilePathAsWString(file_path))
503 << "test case at line number: " << test_case->lineno; 506 << "test case at line number: " << test_case->lineno;
504 } 507 }
505 508
506 } // anonymous namespace 509 } // anonymous namespace
(...skipping 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 reinterpret_cast<ConvertInterfaceLuidToGuid>( 3340 reinterpret_cast<ConvertInterfaceLuidToGuid>(
3338 phlpapi_lib.GetFunctionPointer("ConvertInterfaceLuidToGuid")); 3341 phlpapi_lib.GetFunctionPointer("ConvertInterfaceLuidToGuid"));
3339 3342
3340 if (interface_to_luid && luid_to_guid) { 3343 if (interface_to_luid && luid_to_guid) {
3341 NET_LUID luid; 3344 NET_LUID luid;
3342 EXPECT_EQ(interface_to_luid(it->interface_index, &luid), NO_ERROR); 3345 EXPECT_EQ(interface_to_luid(it->interface_index, &luid), NO_ERROR);
3343 GUID guid; 3346 GUID guid;
3344 EXPECT_EQ(luid_to_guid(&luid, &guid), NO_ERROR); 3347 EXPECT_EQ(luid_to_guid(&luid, &guid), NO_ERROR);
3345 LPOLESTR name; 3348 LPOLESTR name;
3346 StringFromCLSID(guid, &name); 3349 StringFromCLSID(guid, &name);
3347 EXPECT_STREQ(UTF8ToWide(it->name).c_str(), name); 3350 EXPECT_STREQ(base::UTF8ToWide(it->name).c_str(), name);
3348 CoTaskMemFree(name); 3351 CoTaskMemFree(name);
3349 continue; 3352 continue;
3350 } else { 3353 } else {
3351 EXPECT_LT(base::win::GetVersion(), base::win::VERSION_VISTA); 3354 EXPECT_LT(base::win::GetVersion(), base::win::VERSION_VISTA);
3352 EXPECT_LT(it->interface_index, 1u << 24u); // Must fit 0.x.x.x. 3355 EXPECT_LT(it->interface_index, 1u << 24u); // Must fit 0.x.x.x.
3353 EXPECT_NE(it->interface_index, 0u); // 0 means to use default. 3356 EXPECT_NE(it->interface_index, 0u); // 0 means to use default.
3354 } 3357 }
3355 #elif !defined(OS_ANDROID) 3358 #elif !defined(OS_ANDROID)
3356 char name[IF_NAMESIZE]; 3359 char name[IF_NAMESIZE];
3357 EXPECT_TRUE(if_indextoname(it->interface_index, name)); 3360 EXPECT_TRUE(if_indextoname(it->interface_index, name));
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3516 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) { 3519 TEST_P(NetUtilNonUniqueNameTest, IsHostnameNonUnique) {
3517 const NonUniqueNameTestData& test_data = GetParam(); 3520 const NonUniqueNameTestData& test_data = GetParam();
3518 3521
3519 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); 3522 EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname));
3520 } 3523 }
3521 3524
3522 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest, 3525 INSTANTIATE_TEST_CASE_P(, NetUtilNonUniqueNameTest,
3523 testing::ValuesIn(kNonUniqueNameTestData)); 3526 testing::ValuesIn(kNonUniqueNameTestData));
3524 3527
3525 } // namespace net 3528 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.cc ('k') | net/base/net_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698