Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / install_verification / win / imported_module_verification_unittest.cc
blob94692b62cd08914e48bb79702fe9cceb460eea76
1 // Copyright 2013 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.
5 #include "chrome/browser/install_verification/win/imported_module_verification.h"
7 #include <set>
8 #include <utility>
9 #include <vector>
10 #include "chrome/browser/install_verification/win/module_ids.h"
11 #include "chrome/browser/install_verification/win/module_info.h"
12 #include "chrome/browser/install_verification/win/module_verification_test.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 class ImportedModuleVerificationTest : public ModuleVerificationTest {};
17 TEST_F(ImportedModuleVerificationTest, TestCase) {
18 // Note that module verification is temporarily disabled for 64-bit builds.
19 // See crbug.com/316274.
20 #if !defined(_WIN64)
21 std::set<ModuleInfo> loaded_modules;
22 ModuleIDs empty_modules_of_interest;
23 ModuleIDs non_matching_modules_of_interest;
24 ModuleIDs matching_modules_of_interest;
26 // This set of IDs will match because user32.dll imports kernel32.dll.
27 matching_modules_of_interest.insert(
28 std::make_pair(CalculateModuleNameDigest(L"fancy_pants.dll"), 999u));
29 matching_modules_of_interest.insert(
30 std::make_pair(CalculateModuleNameDigest(L"kernel32.dll"), 666u));
31 matching_modules_of_interest.insert(
32 std::make_pair(CalculateModuleNameDigest(L"unit_tests.exe"), 777u));
33 matching_modules_of_interest.insert(
34 std::make_pair(CalculateModuleNameDigest(L"user32.dll"), 888u));
36 non_matching_modules_of_interest.insert(
37 std::make_pair(CalculateModuleNameDigest(L"fancy_pants.dll"), 999u));
39 // With empty loaded_modules, nothing matches.
40 VerifyImportedModules(loaded_modules,
41 empty_modules_of_interest,
42 &ImportedModuleVerificationTest::ReportModule);
43 ASSERT_TRUE(reported_module_ids_.empty());
44 VerifyImportedModules(loaded_modules,
45 non_matching_modules_of_interest,
46 &ImportedModuleVerificationTest::ReportModule);
47 ASSERT_TRUE(reported_module_ids_.empty());
48 VerifyImportedModules(loaded_modules,
49 matching_modules_of_interest,
50 &ImportedModuleVerificationTest::ReportModule);
51 ASSERT_TRUE(reported_module_ids_.empty());
53 // With populated loaded_modules, only the 'matching' module data gives a
54 // match.
55 ASSERT_TRUE(GetLoadedModuleInfoSet(&loaded_modules));
56 VerifyImportedModules(loaded_modules,
57 empty_modules_of_interest,
58 &ImportedModuleVerificationTest::ReportModule);
59 ASSERT_TRUE(reported_module_ids_.empty());
60 VerifyImportedModules(loaded_modules,
61 non_matching_modules_of_interest,
62 &ImportedModuleVerificationTest::ReportModule);
63 ASSERT_TRUE(reported_module_ids_.empty());
64 VerifyImportedModules(loaded_modules,
65 matching_modules_of_interest,
66 &ImportedModuleVerificationTest::ReportModule);
67 ASSERT_EQ(1u, reported_module_ids_.size());
68 ASSERT_EQ(666u, *reported_module_ids_.begin());
69 #endif