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