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

Side by Side Diff: chrome/browser/conflicts/module_info_win_unittest.cc

Issue 2720513005: Add InspectModule() that returns a populated ModuleInspectionResult struct (Closed)
Patch Set: Another Created 3 years, 9 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
OLDNEW
(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 std::unique_ptr<ModuleInspectionResult> inspection_result =
36 InspectModule(path_mapping, module_key);
37
38 EXPECT_STREQ(L"%systemroot%\\system32\\",
39 inspection_result->location.c_str());
40 EXPECT_STREQ(L"kernel32.dll", inspection_result->basename.c_str());
41 EXPECT_STREQ(L"Microsoft\xAE Windows\xAE Operating System",
42 inspection_result->product_name.c_str());
43 EXPECT_STREQ(L"Windows NT BASE API Client DLL",
44 inspection_result->description.c_str());
45 EXPECT_FALSE(inspection_result->version.empty());
46 EXPECT_EQ(inspection_result->certificate_info.type,
47 CertificateType::CERTIFICATE_IN_CATALOG);
48 EXPECT_FALSE(inspection_result->certificate_info.path.empty());
49 EXPECT_STREQ(L"Microsoft Windows",
50 inspection_result->certificate_info.subject.c_str());
51 }
52
53 TEST(ModuleInfoTest, NormalizeInspectionResult) {
54 ModuleInspectionResult test_case;
55 test_case.location = L"%variable%\\PATH\\TO\\file.txt";
56 test_case.version = L"23, 32, 43, 55 win7_rtm.123456-1234";
57 test_case.certificate_info.subject = base::string16(L"signer\0", 7);
58 EXPECT_EQ(7u, test_case.certificate_info.subject.length());
59
60 ModuleInspectionResult expected;
61 expected.location = L"%variable%\\path\\to\\";
62 expected.basename = L"file.txt";
63 expected.version = L"23.32.43.55";
64 expected.certificate_info.subject = L"signer";
65
66 internal::NormalizeInspectionResult(&test_case);
67
68 EXPECT_EQ(test_case.location, expected.location);
69 EXPECT_EQ(test_case.basename, expected.basename);
70 EXPECT_EQ(test_case.version, expected.version);
71 EXPECT_EQ(test_case.certificate_info.subject,
72 expected.certificate_info.subject);
73 }
OLDNEW
« no previous file with comments | « chrome/browser/conflicts/module_info_win.cc ('k') | chrome/browser/win/enumerate_modules_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698