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..fb624fa857f1911f5dd4fa27491168c77f5d5ab5 |
--- /dev/null |
+++ b/chrome/browser/install_module_verifier_unittest_win.cc |
@@ -0,0 +1,54 @@ |
+// 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" |
+ |
+void MockCallback(std::vector<unsigned int>* reported_ids, |
+ unsigned int 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; |
+ |
+ scoped_ptr<base::ListValue> list(new ListValue()); |
+ |
+ VerifyInstalledModules( |
+ list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids))); |
+ ASSERT_TRUE(reported_ids.empty()); |
+ |
+ AddModule(list.get(), ModuleEnumerator::SHELL_EXTENSION, "chrome.dll"); |
+ AddModule( |
+ list.get(), ModuleEnumerator::WINSOCK_MODULE_REGISTRATION, "chrome.dll"); |
+ |
+ VerifyInstalledModules( |
+ list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids))); |
+ ASSERT_TRUE(reported_ids.empty()); |
MAD
2013/09/13 20:15:33
These tests that we properly ignore module types,
erikwright (departed)
2013/09/16 20:04:55
Done.
|
+ |
+ AddModule(list.get(), ModuleEnumerator::LOADED_MODULE, "chrome.dll"); |
+ |
+ VerifyInstalledModules( |
+ list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids))); |
+ ASSERT_EQ(1, reported_ids.size()); |
+ ASSERT_EQ(CalculateInstalledModuleDigest("chrome.dll"), |
+ kExpectedInstallModuleDigests[reported_ids[0]]); |
+} |