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

Side by Side Diff: chrome/browser/install_module_verifier_unittest_win.cc

Issue 23513049: Implement install module verification metric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(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
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;
32
33 scoped_ptr<base::ListValue> list(new ListValue());
34
35 VerifyInstalledModules(
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 VerifyInstalledModules(
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 VerifyInstalledModules(
55 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids)));
56 ASSERT_EQ(1, reported_ids.size());
57 ASSERT_EQ(CanonicalizeModuleName("chrome.dll"),
58 kExpectedInstallModules[reported_ids[0]]);
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698