| 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..3c861ee9c5ebe33d6a8a0c3eb6675eaaa08d94ef
|
| --- /dev/null
|
| +++ b/chrome/browser/install_module_verifier_unittest_win.cc
|
| @@ -0,0 +1,63 @@
|
| +// 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"
|
| +
|
| +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());
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +TEST(InstallModuleVerifierTest, TestCase) {
|
| + std::vector<size_t> reported_ids;
|
| +
|
| + 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]]);
|
| +}
|
|
|