Index: chrome/browser/safe_browsing/environment_data_collection_win_unittest.cc |
diff --git a/chrome/browser/safe_browsing/environment_data_collection_win_unittest.cc b/chrome/browser/safe_browsing/environment_data_collection_win_unittest.cc |
index 50b61cf183a2454e47eedf9e0d0029bbec14111d..b90260eb022d4e1e6cab37ee34872ee5783c710e 100644 |
--- a/chrome/browser/safe_browsing/environment_data_collection_win_unittest.cc |
+++ b/chrome/browser/safe_browsing/environment_data_collection_win_unittest.cc |
@@ -8,11 +8,17 @@ |
#include "base/files/file_path.h" |
#include "base/scoped_native_library.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "base/test/test_reg_util_win.h" |
+#include "base/win/registry.h" |
#include "chrome/common/safe_browsing/csd.pb.h" |
+#include "chrome_elf/chrome_elf_constants.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace { |
+const wchar_t test_dll[] = L"testname.dll"; |
+ |
// Helper function that returns true if a dll with filename |dll_name| is |
// found in |process_report|. |
bool ProcessReportContainsDll( |
@@ -111,3 +117,29 @@ TEST(SafeBrowsingEnvironmentDataCollectionWinTest, RecordLspFeature) { |
ASSERT_TRUE(lsp_feature_found); |
} |
+ |
+TEST(SafeBrowsingEnvironmentDataCollectionWinTest, CollectDllBlacklistData) { |
+ // Ensure that CollectDllBlacklistData correctly adds the set of dll names |
+ // currently stored in the registry to the report. |
+ registry_util::RegistryOverrideManager override_manager; |
+ override_manager.OverrideRegistry(HKEY_CURRENT_USER, L"safe_browsing_test"); |
+ |
+ base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, |
+ blacklist::kRegistryFinchListPath, |
+ KEY_QUERY_VALUE | KEY_SET_VALUE); |
+ |
+ // Check that with an empty registry the blacklisted dlls field is left empty. |
+ safe_browsing::ClientIncidentReport_EnvironmentData_Process process_report; |
+ safe_browsing::CollectDllBlacklistData(&process_report); |
+ EXPECT_EQ(0, process_report.blacklisted_dll_size()); |
+ |
+ // Check that after adding exactly one dll to the registry it appears in the |
+ // process report. |
+ blacklist_registry_key.WriteValue(test_dll, test_dll); |
+ safe_browsing::CollectDllBlacklistData(&process_report); |
+ ASSERT_EQ(1, process_report.blacklisted_dll_size()); |
+ |
+ std::wstring process_report_dll = |
grt (UTC plus 2)
2014/06/19 20:06:59
use base::string16 rather than std::wstring to avo
krstnmnlsn
2014/06/19 22:13:15
Done.
|
+ base::UTF8ToWide(process_report.blacklisted_dll(0)); |
+ EXPECT_EQ(std::wstring(test_dll), process_report_dll); |
+} |
grt (UTC plus 2)
2014/06/19 20:06:59
please add a test for the case where the registry
krstnmnlsn
2014/06/19 22:13:15
Done.
|