diff options
Diffstat (limited to 'chrome/browser/enumerate_modules_model_unittest_win.cc')
-rw-r--r-- | chrome/browser/enumerate_modules_model_unittest_win.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/browser/enumerate_modules_model_unittest_win.cc b/chrome/browser/enumerate_modules_model_unittest_win.cc index 841c420..7aa6b63 100644 --- a/chrome/browser/enumerate_modules_model_unittest_win.cc +++ b/chrome/browser/enumerate_modules_model_unittest_win.cc @@ -190,3 +190,34 @@ TEST_F(EnumerateModulesTest, MatchFunction) { ModuleEnumerator::Match(test, blacklist)); } } + +const struct CollapsePathList { + string16 expected_result; + string16 test_case; +} kCollapsePathList[] = { + // Negative testing (should not collapse this path). + { ASCIIToUTF16("c:\\a\\a.dll"), ASCIIToUTF16("c:\\a\\a.dll") }, + // These two are to test that we select the maximum collapsed path. + { ASCIIToUTF16("%foo%\\a.dll"), ASCIIToUTF16("c:\\foo\\a.dll") }, + { ASCIIToUTF16("%x%\\a.dll"), ASCIIToUTF16("c:\\foo\\bar\\a.dll") }, +}; + +TEST_F(EnumerateModulesTest, CollapsePath) { + scoped_refptr<ModuleEnumerator> module_enumerator(new ModuleEnumerator(NULL)); + module_enumerator->path_mapping_.clear(); + module_enumerator->path_mapping_.push_back( + std::make_pair(L"c:\\foo\\", L"%foo%")); + module_enumerator->path_mapping_.push_back( + std::make_pair(L"c:\\foo\\bar\\", L"%x%")); + + for (size_t i = 0; i < arraysize(kCollapsePathList); ++i) { + ModuleEnumerator::Module module; + module.location = kCollapsePathList[i].test_case; + module_enumerator->CollapsePath(&module); + + SCOPED_TRACE("Test case no " + base::IntToString(i) + + ": '" + UTF16ToASCII(kCollapsePathList[i].expected_result) + + "'"); + EXPECT_EQ(kCollapsePathList[i].expected_result, module.location); + } +} |