Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / install_verification / win / loaded_module_verification_unittest.cc
blob6cff3af1e7ae5995f69631ea78250c5132e4129d
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/loaded_module_verification.h"
7 #include "chrome/browser/install_verification/win/module_verification_test.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 class LoadedModuleVerificationTest : public ModuleVerificationTest { };
12 TEST_F(LoadedModuleVerificationTest, TestCase) {
13 std::set<ModuleInfo> loaded_modules;
14 ModuleIDs empty_modules_of_interest;
15 ModuleIDs non_matching_modules_of_interest;
16 ModuleIDs matching_modules_of_interest;
18 matching_modules_of_interest.insert(
19 std::make_pair(CalculateModuleNameDigest(L"fancy_pants.dll"), 999u));
20 matching_modules_of_interest.insert(
21 std::make_pair(CalculateModuleNameDigest(L"advapi32.dll"), 666u));
22 matching_modules_of_interest.insert(
23 std::make_pair(CalculateModuleNameDigest(L"unit_tests.exe"), 777u));
24 matching_modules_of_interest.insert(
25 std::make_pair(CalculateModuleNameDigest(L"user32.dll"), 888u));
27 non_matching_modules_of_interest.insert(
28 std::make_pair(CalculateModuleNameDigest(L"fancy_pants.dll"), 999u));
30 // With empty loaded_modules, nothing matches.
31 VerifyLoadedModules(loaded_modules,
32 empty_modules_of_interest,
33 &ModuleVerificationTest::ReportModule);
34 ASSERT_TRUE(reported_module_ids_.empty());
35 VerifyLoadedModules(loaded_modules,
36 non_matching_modules_of_interest,
37 &ModuleVerificationTest::ReportModule);
38 ASSERT_TRUE(reported_module_ids_.empty());
39 VerifyLoadedModules(loaded_modules,
40 matching_modules_of_interest,
41 &ModuleVerificationTest::ReportModule);
42 ASSERT_TRUE(reported_module_ids_.empty());
44 // With populated loaded_modules, only the 'matching' module data gives a
45 // match.
46 ASSERT_TRUE(GetLoadedModuleInfoSet(&loaded_modules));
47 VerifyLoadedModules(loaded_modules,
48 empty_modules_of_interest,
49 &ModuleVerificationTest::ReportModule);
50 ASSERT_TRUE(reported_module_ids_.empty());
51 VerifyLoadedModules(loaded_modules,
52 non_matching_modules_of_interest,
53 &ModuleVerificationTest::ReportModule);
54 ASSERT_TRUE(reported_module_ids_.empty());
55 VerifyLoadedModules(loaded_modules,
56 matching_modules_of_interest,
57 &ModuleVerificationTest::ReportModule);
58 ASSERT_EQ(3u, reported_module_ids_.size());
59 ASSERT_NE(reported_module_ids_.end(), reported_module_ids_.find(666u));
60 ASSERT_NE(reported_module_ids_.end(), reported_module_ids_.find(777u));
61 ASSERT_NE(reported_module_ids_.end(), reported_module_ids_.find(888u));