| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/conflicts/module_info_win.h" |
| 6 |
| 7 #include <memory> |
| 8 #include <string> |
| 9 |
| 10 #include "base/environment.h" |
| 11 #include "base/files/file_path.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 namespace { |
| 15 |
| 16 base::FilePath GetKernel32DllFilePath() { |
| 17 std::unique_ptr<base::Environment> env = base::Environment::Create(); |
| 18 std::string sysroot; |
| 19 EXPECT_TRUE(env->GetVar("SYSTEMROOT", &sysroot)); |
| 20 |
| 21 base::FilePath path = |
| 22 base::FilePath::FromUTF8Unsafe(sysroot).Append(L"system32\\kernel32.dll"); |
| 23 |
| 24 return path; |
| 25 } |
| 26 |
| 27 } // namespace |
| 28 |
| 29 TEST(ModuleInfoTest, InspectModule) { |
| 30 ModuleInfoKey module_key = {GetKernel32DllFilePath(), 0, 0, 1}; |
| 31 StringMapping path_mapping = GetEnvironmentVariablesMapping({ |
| 32 L"SystemRoot", |
| 33 }); |
| 34 |
| 35 ModuleInfoData module_data = InspectModule(path_mapping, module_key); |
| 36 |
| 37 EXPECT_TRUE(module_data.inspected); |
| 38 EXPECT_STREQ(L"%systemroot%\\system32\\", module_data.location.c_str()); |
| 39 EXPECT_STREQ(L"kernel32.dll", module_data.basename.c_str()); |
| 40 EXPECT_STREQ(L"Microsoft\xAE Windows\xAE Operating System", |
| 41 module_data.product_name.c_str()); |
| 42 EXPECT_STREQ(L"Windows NT BASE API Client DLL", |
| 43 module_data.description.c_str()); |
| 44 EXPECT_FALSE(module_data.version.empty()); |
| 45 EXPECT_EQ(module_data.certificate_info.type, |
| 46 CertificateType::CERTIFICATE_IN_CATALOG); |
| 47 EXPECT_FALSE(module_data.certificate_info.path.empty()); |
| 48 EXPECT_STREQ(L"Microsoft Windows", |
| 49 module_data.certificate_info.subject.c_str()); |
| 50 } |
| OLD | NEW |