OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_version_info.h" | 5 #include "base/file_version_info.h" |
| 6 #include "base/file_version_info_win.h" |
6 #include "chrome_frame/utils.h" | 7 #include "chrome_frame/utils.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
9 const wchar_t kChannelName[] = L"-dev"; | 10 const wchar_t kChannelName[] = L"-dev"; |
10 const wchar_t kSuffix[] = L"-fix"; | 11 const wchar_t kSuffix[] = L"-fix"; |
11 | 12 |
12 TEST(UtilTests, GetModuleVersionTest) { | 13 TEST(UtilTests, GetModuleVersionTest) { |
13 HMODULE mod = GetModuleHandle(L"kernel32.dll"); | 14 HMODULE mod = GetModuleHandle(L"kernel32.dll"); |
14 EXPECT_NE(mod, static_cast<HMODULE>(NULL)); | 15 EXPECT_NE(mod, static_cast<HMODULE>(NULL)); |
15 wchar_t path[MAX_PATH] = {0}; | 16 wchar_t path[MAX_PATH] = {0}; |
16 GetModuleFileName(mod, path, arraysize(path)); | 17 GetModuleFileName(mod, path, arraysize(path)); |
17 | 18 |
18 // Use the method that goes to disk | 19 // Use the method that goes to disk |
19 scoped_ptr<FileVersionInfo> base_info( | 20 scoped_ptr<FileVersionInfo> base_info( |
20 FileVersionInfo::CreateFileVersionInfo(path)); | 21 FileVersionInfo::CreateFileVersionInfo(path)); |
21 EXPECT_TRUE(base_info.get() != NULL); | 22 EXPECT_TRUE(base_info.get() != NULL); |
22 | 23 |
23 // Use the method that doesn't go to disk | 24 // Use the method that doesn't go to disk |
24 uint32 low = 0, high = 0; | 25 uint32 low = 0, high = 0; |
25 EXPECT_TRUE(GetModuleVersion(mod, &high, &low)); | 26 EXPECT_TRUE(GetModuleVersion(mod, &high, &low)); |
26 EXPECT_NE(high, 0); | 27 EXPECT_NE(high, 0); |
27 EXPECT_NE(low, 0); | 28 EXPECT_NE(low, 0); |
28 | 29 |
29 // Make sure they give the same results. | 30 // Make sure they give the same results. |
30 VS_FIXEDFILEINFO* fixed_info = base_info->fixed_file_info(); | 31 FileVersionInfoWin* base_info_win = |
| 32 static_cast<FileVersionInfoWin*>(base_info.get()); |
| 33 VS_FIXEDFILEINFO* fixed_info = base_info_win->fixed_file_info(); |
31 EXPECT_TRUE(fixed_info != NULL); | 34 EXPECT_TRUE(fixed_info != NULL); |
32 | 35 |
33 EXPECT_EQ(fixed_info->dwFileVersionMS, static_cast<DWORD>(high)); | 36 EXPECT_EQ(fixed_info->dwFileVersionMS, static_cast<DWORD>(high)); |
34 EXPECT_EQ(fixed_info->dwFileVersionLS, static_cast<DWORD>(low)); | 37 EXPECT_EQ(fixed_info->dwFileVersionLS, static_cast<DWORD>(low)); |
35 } | 38 } |
36 | 39 |
37 TEST(UtilTests, HaveSameOrigin) { | 40 TEST(UtilTests, HaveSameOrigin) { |
38 struct OriginCompare { | 41 struct OriginCompare { |
39 const char* a; | 42 const char* a; |
40 const char* b; | 43 const char* b; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 105 |
103 std::wstring str_guid(GuidToString(test_guid)); | 106 std::wstring str_guid(GuidToString(test_guid)); |
104 EXPECT_EQ(0, str_guid.compare(compare)); | 107 EXPECT_EQ(0, str_guid.compare(compare)); |
105 EXPECT_EQ(static_cast<size_t>(lstrlenW(compare)), str_guid.length()); | 108 EXPECT_EQ(static_cast<size_t>(lstrlenW(compare)), str_guid.length()); |
106 } | 109 } |
107 | 110 |
108 TEST(UtilTests, GetTempInternetFiles) { | 111 TEST(UtilTests, GetTempInternetFiles) { |
109 FilePath path = GetIETemporaryFilesFolder(); | 112 FilePath path = GetIETemporaryFilesFolder(); |
110 EXPECT_FALSE(path.empty()); | 113 EXPECT_FALSE(path.empty()); |
111 } | 114 } |
OLD | NEW |