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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/install_module_verifier_unittest_win.cc
diff --git a/chrome/browser/install_module_verifier_unittest_win.cc b/chrome/browser/install_module_verifier_unittest_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e17b4941ae34b04e9f92a0249dc089b826f98a6e
--- /dev/null
+++ b/chrome/browser/install_module_verifier_unittest_win.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/install_module_verifier_win.h"
+
+#include <string>
+#include <vector>
+#include "base/bind.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "chrome/browser/enumerate_modules_model_win.h"
+#include "chrome/browser/expected_install_modules_win.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
MAD 2013/09/17 15:20:21 unnamed namespace?
+void MockCallback(std::vector<unsigned int>* reported_ids,
+ size_t module_id) {
+ reported_ids->push_back(module_id);
+}
+
+void AddModule(base::ListValue* list,
+ ModuleEnumerator::ModuleType type,
+ const std::string& name) {
+ scoped_ptr<base::DictionaryValue> data(new DictionaryValue());
+ data->SetInteger("type", type);
+ data->SetString("name", name);
+ list->Append(data.release());
+}
+
+TEST(InstallModuleVerifierTest, TestCase) {
+ std::vector<unsigned int> reported_ids;
MAD 2013/09/17 15:20:21 unsigned int -> size_t?
+
+ scoped_ptr<base::ListValue> list(new ListValue());
+
+ VerifyModules(
+ list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids)));
+ ASSERT_TRUE(reported_ids.empty());
+
+ // WinSock modules are ignored.
+ AddModule(list.get(), ModuleEnumerator::SHELL_EXTENSION, "chrome.dll");
+ // Shell Extension modules are ignored.
+ AddModule(
+ list.get(), ModuleEnumerator::WINSOCK_MODULE_REGISTRATION, "chrome.dll");
+ // Unexpected modules are ignored.
+ AddModule(list.get(), ModuleEnumerator::LOADED_MODULE, "fancy_pants.dll");
+
+ VerifyModules(
+ list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids)));
+ ASSERT_TRUE(reported_ids.empty());
+
+ // Expected, Loaded modules are reported.
+ AddModule(list.get(), ModuleEnumerator::LOADED_MODULE, "chrome.dll");
+
+ VerifyModules(
+ list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids)));
+ ASSERT_EQ(1, reported_ids.size());
+ ASSERT_EQ(CanonicalizeModuleName(L"chrome.dll"),
+ kExpectedInstallModules[reported_ids[0]]);
+}

Powered by Google App Engine
This is Rietveld 408576698