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

Unified Diff: chrome/browser/safe_browsing/module_integrity_verifier_win_unittest.cc

Issue 440753002: The incident reporting service now calls VerifyModule. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/safe_browsing/module_integrity_verifier_win_unittest.cc
diff --git a/chrome/browser/safe_browsing/module_integrity_verifier_win_unittest.cc b/chrome/browser/safe_browsing/module_integrity_verifier_win_unittest.cc
index 11662d1cad769825f47f000d3e454149312accf1..93273c28cb0f77ea7ce469656ea0a29b632bf629 100644
--- a/chrome/browser/safe_browsing/module_integrity_verifier_win_unittest.cc
+++ b/chrome/browser/safe_browsing/module_integrity_verifier_win_unittest.cc
@@ -10,17 +10,11 @@
#include "base/path_service.h"
#include "base/scoped_native_library.h"
#include "base/win/pe_image.h"
+#include "chrome/browser/safe_browsing/module_integrity_unittest_util_win.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace safe_browsing {
-namespace {
-
-const wchar_t kTestDllName[] = L"verifier_test_dll.dll";
-const char kTestExportName[] = "DummyExport";
-
-} // namespace
-
class SafeBrowsingModuleVerifierWinTest : public testing::Test {
protected:
void SetUpTestDllAndPEImages() {
@@ -39,12 +33,12 @@ class SafeBrowsingModuleVerifierWinTest : public testing::Test {
void LoadModule() {
mem_dll_handle_.Reset(
- LoadNativeLibrary(base::FilePath(kTestDllName), NULL));
+ LoadNativeLibrary(base::FilePath(kTestDllNames[0]), NULL));
ASSERT_TRUE(mem_dll_handle_.is_valid());
}
void GetMemModuleHandle(HMODULE* mem_handle) {
- *mem_handle = GetModuleHandle(kTestDllName);
+ *mem_handle = GetModuleHandle(kTestDllNames[0]);
ASSERT_NE(static_cast<HMODULE>(NULL), *mem_handle);
}
@@ -94,14 +88,14 @@ TEST_F(SafeBrowsingModuleVerifierWinTest, VerifyModuleUnmodified) {
std::set<std::string> modified_exports;
// Call VerifyModule before the module has been loaded, should fail.
EXPECT_EQ(MODULE_STATE_UNKNOWN,
- VerifyModule(kTestDllName, &modified_exports));
+ VerifyModule(kTestDllNames[0], &modified_exports));
EXPECT_EQ(0, modified_exports.size());
// On loading, the module should be identical (up to relocations) in memory as
// on disk.
SetUpTestDllAndPEImages();
EXPECT_EQ(MODULE_STATE_UNMODIFIED,
- VerifyModule(kTestDllName, &modified_exports));
+ VerifyModule(kTestDllNames[0], &modified_exports));
EXPECT_EQ(0, modified_exports.size());
}
@@ -110,7 +104,7 @@ TEST_F(SafeBrowsingModuleVerifierWinTest, VerifyModuleModified) {
// Confirm the module is identical in memory as on disk before we begin.
SetUpTestDllAndPEImages();
EXPECT_EQ(MODULE_STATE_UNMODIFIED,
- VerifyModule(kTestDllName, &modified_exports));
+ VerifyModule(kTestDllNames[0], &modified_exports));
uint8_t* mem_code_addr = NULL;
uint8_t* disk_code_addr = NULL;
@@ -134,7 +128,7 @@ TEST_F(SafeBrowsingModuleVerifierWinTest, VerifyModuleModified) {
// VerifyModule should detect the change.
EXPECT_EQ(MODULE_STATE_MODIFIED,
- VerifyModule(kTestDllName, &modified_exports));
+ VerifyModule(kTestDllNames[0], &modified_exports));
}
TEST_F(SafeBrowsingModuleVerifierWinTest, VerifyModuleExportModified) {
@@ -142,14 +136,14 @@ TEST_F(SafeBrowsingModuleVerifierWinTest, VerifyModuleExportModified) {
// Confirm the module is identical in memory as on disk before we begin.
SetUpTestDllAndPEImages();
EXPECT_EQ(MODULE_STATE_UNMODIFIED,
- VerifyModule(kTestDllName, &modified_exports));
+ VerifyModule(kTestDllNames[0], &modified_exports));
modified_exports.clear();
// Edit the exported function, VerifyModule should now return the function
// name in modified_exports.
EditExport();
EXPECT_EQ(MODULE_STATE_MODIFIED,
- VerifyModule(kTestDllName, &modified_exports));
+ VerifyModule(kTestDllNames[0], &modified_exports));
EXPECT_EQ(1, modified_exports.size());
EXPECT_EQ(0, std::string(kTestExportName).compare(*modified_exports.begin()));
}

Powered by Google App Engine
This is Rietveld 408576698