Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 unsigned int 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 AddModule(list.get(), ModuleEnumerator::SHELL_EXTENSION, "chrome.dll"); | |
| 40 AddModule( | |
| 41 list.get(), ModuleEnumerator::WINSOCK_MODULE_REGISTRATION, "chrome.dll"); | |
| 42 | |
| 43 VerifyInstalledModules( | |
| 44 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids))); | |
| 45 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.
| |
| 46 | |
| 47 AddModule(list.get(), ModuleEnumerator::LOADED_MODULE, "chrome.dll"); | |
| 48 | |
| 49 VerifyInstalledModules( | |
| 50 list.get(), base::Bind(&MockCallback, base::Unretained(&reported_ids))); | |
| 51 ASSERT_EQ(1, reported_ids.size()); | |
| 52 ASSERT_EQ(CalculateInstalledModuleDigest("chrome.dll"), | |
| 53 kExpectedInstallModuleDigests[reported_ids[0]]); | |
| 54 } | |
| OLD | NEW |