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

Side by Side Diff: base/file_version_info_unittest.cc

Issue 193047: Fix to use FilePath version of PathService::Get.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | « base/file_version_info.cc ('k') | chrome/browser/blocked_popup_container_interactive_uitest.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/file_version_info.h" 8 #include "base/file_version_info.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace { 11 namespace {
12 12
13 class FileVersionInfoTest : public testing::Test { 13 class FileVersionInfoTest : public testing::Test {
14 }; 14 };
15 15
16 std::wstring GetTestDataPath() { 16 FilePath GetTestDataPath() {
17 std::wstring path; 17 FilePath path;
18 PathService::Get(base::DIR_SOURCE_ROOT, &path); 18 PathService::Get(base::DIR_SOURCE_ROOT, &path);
19 file_util::AppendToPath(&path, L"base"); 19 path = path.AppendASCII("base");
20 file_util::AppendToPath(&path, L"data"); 20 path = path.AppendASCII("data");
21 file_util::AppendToPath(&path, L"file_version_info_unittest"); 21 path = path.AppendASCII("file_version_info_unittest");
22 return path; 22 return path;
23 } 23 }
24 24
25 } 25 }
26 26
27 #ifdef OS_WIN 27 #ifdef OS_WIN
28 TEST(FileVersionInfoTest, HardCodedProperties) { 28 TEST(FileVersionInfoTest, HardCodedProperties) {
29 const wchar_t* kDLLNames[] = { 29 const wchar_t* kDLLNames[] = {
30 L"FileVersionInfoTest1.dll" 30 L"FileVersionInfoTest1.dll"
31 }; 31 };
32 32
33 const wchar_t* kExpectedValues[1][15] = { 33 const wchar_t* kExpectedValues[1][15] = {
34 // FileVersionInfoTest.dll 34 // FileVersionInfoTest.dll
35 L"Goooooogle", // company_name 35 L"Goooooogle", // company_name
36 L"Google", // company_short_name 36 L"Google", // company_short_name
37 L"This is the product name", // product_name 37 L"This is the product name", // product_name
38 L"This is the product short name", // product_short_name 38 L"This is the product short name", // product_short_name
39 L"The Internal Name", // internal_name 39 L"The Internal Name", // internal_name
40 L"4.3.2.1", // product_version 40 L"4.3.2.1", // product_version
41 L"Private build property", // private_build 41 L"Private build property", // private_build
42 L"Special build property", // special_build 42 L"Special build property", // special_build
43 L"This is a particularly interesting comment", // comments 43 L"This is a particularly interesting comment", // comments
44 L"This is the original filename", // original_filename 44 L"This is the original filename", // original_filename
45 L"This is my file description", // file_description 45 L"This is my file description", // file_description
46 L"1.2.3.4", // file_version 46 L"1.2.3.4", // file_version
47 L"This is the legal copyright", // legal_copyright 47 L"This is the legal copyright", // legal_copyright
48 L"This is the legal trademarks", // legal_trademarks 48 L"This is the legal trademarks", // legal_trademarks
49 L"This is the last change", // last_change 49 L"This is the last change", // last_change
50
51 }; 50 };
52 51
53 for (int i = 0; i < arraysize(kDLLNames); ++i) { 52 for (int i = 0; i < arraysize(kDLLNames); ++i) {
54 std::wstring dll_path = GetTestDataPath(); 53 FilePath dll_path = GetTestDataPath();
55 file_util::AppendToPath(&dll_path, kDLLNames[i]); 54 dll_path = dll_path.Append(kDLLNames[i]);
56 55
57 scoped_ptr<FileVersionInfo> version_info( 56 scoped_ptr<FileVersionInfo> version_info(
58 FileVersionInfo::CreateFileVersionInfo(dll_path)); 57 FileVersionInfo::CreateFileVersionInfo(dll_path));
59 58
60 int j = 0; 59 int j = 0;
61 EXPECT_EQ(kExpectedValues[i][j++], version_info->company_name()); 60 EXPECT_EQ(kExpectedValues[i][j++], version_info->company_name());
62 EXPECT_EQ(kExpectedValues[i][j++], version_info->company_short_name()); 61 EXPECT_EQ(kExpectedValues[i][j++], version_info->company_short_name());
63 EXPECT_EQ(kExpectedValues[i][j++], version_info->product_name()); 62 EXPECT_EQ(kExpectedValues[i][j++], version_info->product_name());
64 EXPECT_EQ(kExpectedValues[i][j++], version_info->product_short_name()); 63 EXPECT_EQ(kExpectedValues[i][j++], version_info->product_short_name());
65 EXPECT_EQ(kExpectedValues[i][j++], version_info->internal_name()); 64 EXPECT_EQ(kExpectedValues[i][j++], version_info->internal_name());
(...skipping 20 matching lines...) Expand all
86 85
87 const bool kExpected[] = { 86 const bool kExpected[] = {
88 true, 87 true,
89 false, 88 false,
90 }; 89 };
91 90
92 // Test consistency check. 91 // Test consistency check.
93 ASSERT_EQ(arraysize(kDLLNames), arraysize(kExpected)); 92 ASSERT_EQ(arraysize(kDLLNames), arraysize(kExpected));
94 93
95 for (int i = 0; i < arraysize(kDLLNames); ++i) { 94 for (int i = 0; i < arraysize(kDLLNames); ++i) {
96 std::wstring dll_path = GetTestDataPath(); 95 FilePath dll_path = GetTestDataPath();
97 file_util::AppendToPath(&dll_path, kDLLNames[i]); 96 dll_path = dll_path.Append(kDLLNames[i]);
98 97
99 scoped_ptr<FileVersionInfo> version_info( 98 scoped_ptr<FileVersionInfo> version_info(
100 FileVersionInfo::CreateFileVersionInfo(dll_path)); 99 FileVersionInfo::CreateFileVersionInfo(dll_path));
101 100
102 EXPECT_EQ(kExpected[i], version_info->is_official_build()); 101 EXPECT_EQ(kExpected[i], version_info->is_official_build());
103 } 102 }
104 } 103 }
105 #endif 104 #endif
106 105
107 TEST(FileVersionInfoTest, CustomProperties) { 106 TEST(FileVersionInfoTest, CustomProperties) {
108 std::wstring dll_path = GetTestDataPath(); 107 FilePath dll_path = GetTestDataPath();
109 file_util::AppendToPath(&dll_path, L"FileVersionInfoTest1.dll"); 108 dll_path = dll_path.AppendASCII("FileVersionInfoTest1.dll");
110 109
111 scoped_ptr<FileVersionInfo> version_info( 110 scoped_ptr<FileVersionInfo> version_info(
112 FileVersionInfo::CreateFileVersionInfo(dll_path)); 111 FileVersionInfo::CreateFileVersionInfo(dll_path));
113 112
114 // Test few existing properties. 113 // Test few existing properties.
115 std::wstring str; 114 std::wstring str;
116 #ifdef OS_WIN 115 #ifdef OS_WIN
117 EXPECT_TRUE(version_info->GetValue(L"Custom prop 1", &str)); 116 EXPECT_TRUE(version_info->GetValue(L"Custom prop 1", &str));
118 EXPECT_EQ(L"Un", str); 117 EXPECT_EQ(L"Un", str);
119 EXPECT_EQ(L"Un", version_info->GetStringValue(L"Custom prop 1")); 118 EXPECT_EQ(L"Un", version_info->GetStringValue(L"Custom prop 1"));
120 119
121 EXPECT_TRUE(version_info->GetValue(L"Custom prop 2", &str)); 120 EXPECT_TRUE(version_info->GetValue(L"Custom prop 2", &str));
122 EXPECT_EQ(L"Deux", str); 121 EXPECT_EQ(L"Deux", str);
123 EXPECT_EQ(L"Deux", version_info->GetStringValue(L"Custom prop 2")); 122 EXPECT_EQ(L"Deux", version_info->GetStringValue(L"Custom prop 2"));
124 123
125 EXPECT_TRUE(version_info->GetValue(L"Custom prop 3", &str)); 124 EXPECT_TRUE(version_info->GetValue(L"Custom prop 3", &str));
126 EXPECT_EQ(L"1600 Amphitheatre Parkway Mountain View, CA 94043", str); 125 EXPECT_EQ(L"1600 Amphitheatre Parkway Mountain View, CA 94043", str);
127 EXPECT_EQ(L"1600 Amphitheatre Parkway Mountain View, CA 94043", 126 EXPECT_EQ(L"1600 Amphitheatre Parkway Mountain View, CA 94043",
128 version_info->GetStringValue(L"Custom prop 3")); 127 version_info->GetStringValue(L"Custom prop 3"));
129 #endif 128 #endif
130 129
131 // Test an non-existing property. 130 // Test an non-existing property.
132 EXPECT_FALSE(version_info->GetValue(L"Unknown property", &str)); 131 EXPECT_FALSE(version_info->GetValue(L"Unknown property", &str));
133 EXPECT_EQ(L"", version_info->GetStringValue(L"Unknown property")); 132 EXPECT_EQ(L"", version_info->GetStringValue(L"Unknown property"));
134 } 133 }
OLDNEW
« no previous file with comments | « base/file_version_info.cc ('k') | chrome/browser/blocked_popup_container_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698