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

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: Merge and final nits. 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 namespace {
17
18 void MockCallback(std::vector<unsigned int>* reported_ids,
19 size_t module_id) {
20 reported_ids->push_back(module_id);
21 }
22
23 void AddModule(base::ListValue* list,
24 ModuleEnumerator::ModuleType type,
25 const std::string& name) {
26 scoped_ptr<base::DictionaryValue> data(new DictionaryValue());
27 data->SetInteger("type", type);
28 data->SetString("name", name);
29 list->Append(data.release());
30 }
31
32 } // namespace
33
34 TEST(InstallModuleVerifierTest, TestCase) {
35 std::vector<size_t> reported_ids;
36
37 scoped_ptr<base::ListValue> list(new ListValue());
38
39 VerifyModules(
40 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids)));
41 ASSERT_TRUE(reported_ids.empty());
42
43 // WinSock modules are ignored.
44 AddModule(list.get(), ModuleEnumerator::SHELL_EXTENSION, "chrome.dll");
45 // Shell Extension modules are ignored.
46 AddModule(
47 list.get(), ModuleEnumerator::WINSOCK_MODULE_REGISTRATION, "chrome.dll");
48 // Unexpected modules are ignored.
49 AddModule(list.get(), ModuleEnumerator::LOADED_MODULE, "fancy_pants.dll");
50
51 VerifyModules(
52 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids)));
53 ASSERT_TRUE(reported_ids.empty());
54
55 // Expected, Loaded modules are reported.
56 AddModule(list.get(), ModuleEnumerator::LOADED_MODULE, "chrome.dll");
57
58 VerifyModules(
59 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids)));
60 ASSERT_EQ(1, reported_ids.size());
61 ASSERT_EQ(CanonicalizeModuleName(L"chrome.dll"),
62 kExpectedInstallModules[reported_ids[0]]);
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698