OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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. | |
4 | |
5 #include "chrome/browser/install_module_verifier_win.h" | |
6 | |
7 #include <string> | |
8 #include <vector> | |
9 #include "base/bind.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/values.h" | |
12 #include "chrome/browser/enumerate_modules_model_win.h" | |
13 #include "chrome/browser/expected_install_modules_win.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 | |
MAD
2013/09/17 15:20:21
unnamed namespace?
| |
16 void MockCallback(std::vector<unsigned int>* reported_ids, | |
17 size_t module_id) { | |
18 reported_ids->push_back(module_id); | |
19 } | |
20 | |
21 void AddModule(base::ListValue* list, | |
22 ModuleEnumerator::ModuleType type, | |
23 const std::string& name) { | |
24 scoped_ptr<base::DictionaryValue> data(new DictionaryValue()); | |
25 data->SetInteger("type", type); | |
26 data->SetString("name", name); | |
27 list->Append(data.release()); | |
28 } | |
29 | |
30 TEST(InstallModuleVerifierTest, TestCase) { | |
31 std::vector<unsigned int> reported_ids; | |
MAD
2013/09/17 15:20:21
unsigned int -> size_t?
| |
32 | |
33 scoped_ptr<base::ListValue> list(new ListValue()); | |
34 | |
35 VerifyModules( | |
36 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids))); | |
37 ASSERT_TRUE(reported_ids.empty()); | |
38 | |
39 // WinSock modules are ignored. | |
40 AddModule(list.get(), ModuleEnumerator::SHELL_EXTENSION, "chrome.dll"); | |
41 // Shell Extension modules are ignored. | |
42 AddModule( | |
43 list.get(), ModuleEnumerator::WINSOCK_MODULE_REGISTRATION, "chrome.dll"); | |
44 // Unexpected modules are ignored. | |
45 AddModule(list.get(), ModuleEnumerator::LOADED_MODULE, "fancy_pants.dll"); | |
46 | |
47 VerifyModules( | |
48 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids))); | |
49 ASSERT_TRUE(reported_ids.empty()); | |
50 | |
51 // Expected, Loaded modules are reported. | |
52 AddModule(list.get(), ModuleEnumerator::LOADED_MODULE, "chrome.dll"); | |
53 | |
54 VerifyModules( | |
55 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids))); | |
56 ASSERT_EQ(1, reported_ids.size()); | |
57 ASSERT_EQ(CanonicalizeModuleName(L"chrome.dll"), | |
58 kExpectedInstallModules[reported_ids[0]]); | |
59 } | |
OLD | NEW |