| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/win/enumerate_modules_model.h" | 5 #include "chrome/browser/win/enumerate_modules_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 EXPECT_EQ(expected.type, test.type); | 73 EXPECT_EQ(expected.type, test.type); |
| 74 EXPECT_EQ(expected.status, test.status); | 74 EXPECT_EQ(expected.status, test.status); |
| 75 EXPECT_STREQ(expected.location.c_str(), test.location.c_str()); | 75 EXPECT_STREQ(expected.location.c_str(), test.location.c_str()); |
| 76 EXPECT_STREQ(expected.name.c_str(), test.name.c_str()); | 76 EXPECT_STREQ(expected.name.c_str(), test.name.c_str()); |
| 77 EXPECT_STREQ(expected.product_name.c_str(), test.product_name.c_str()); | 77 EXPECT_STREQ(expected.product_name.c_str(), test.product_name.c_str()); |
| 78 EXPECT_STREQ(expected.description.c_str(), test.description.c_str()); | 78 EXPECT_STREQ(expected.description.c_str(), test.description.c_str()); |
| 79 EXPECT_STREQ(expected.version.c_str(), test.version.c_str()); | 79 EXPECT_STREQ(expected.version.c_str(), test.version.c_str()); |
| 80 EXPECT_EQ(expected.recommended_action, test.recommended_action); | 80 EXPECT_EQ(expected.recommended_action, test.recommended_action); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | |
| 84 const ModuleEnumerator::Module kStandardModule = | |
| 85 { kType, kStatus, L"c:\\foo\\bar.dll", L"", L"Prod", L"Desc", L"1.0", | |
| 86 ModuleEnumerator::NONE }; | |
| 87 const ModuleEnumerator::Module kStandardModuleNoDescription = | |
| 88 { kType, kStatus, L"c:\\foo\\bar.dll", L"", L"Prod", L"", L"1.0", | |
| 89 ModuleEnumerator::NONE }; | |
| 90 const ModuleEnumerator::Module kStandardModuleNoSignature = | |
| 91 { kType, kStatus, L"c:\\foo\\bar.dll", L"", L"Prod", L"Desc", L"1.0", | |
| 92 ModuleEnumerator::NONE }; | |
| 93 | |
| 94 const struct CollapsePathList { | |
| 95 base::string16 expected_result; | |
| 96 base::string16 test_case; | |
| 97 } kCollapsePathList[] = { | |
| 98 // Negative testing (should not collapse this path). | |
| 99 { base::ASCIIToUTF16("c:\\a\\a.dll"), base::ASCIIToUTF16("c:\\a\\a.dll") }, | |
| 100 // These two are to test that we select the maximum collapsed path. | |
| 101 { base::ASCIIToUTF16("%foo%\\a.dll"), base::ASCIIToUTF16("c:\\foo\\a.dll") }, | |
| 102 { base::ASCIIToUTF16("%x%\\a.dll"), | |
| 103 base::ASCIIToUTF16("c:\\foo\\bar\\a.dll") }, | |
| 104 }; | |
| 105 | |
| 106 TEST_F(EnumerateModulesTest, CollapsePath) { | |
| 107 base::test::ScopedTaskScheduler scoped_task_scheduler; | |
| 108 ModuleEnumerator module_enumerator(nullptr); | |
| 109 module_enumerator.path_mapping_.clear(); | |
| 110 module_enumerator.path_mapping_.push_back( | |
| 111 std::make_pair(L"c:\\foo\\", L"%foo%")); | |
| 112 module_enumerator.path_mapping_.push_back( | |
| 113 std::make_pair(L"c:\\foo\\bar\\", L"%x%")); | |
| 114 | |
| 115 for (size_t i = 0; i < arraysize(kCollapsePathList); ++i) { | |
| 116 ModuleEnumerator::Module module; | |
| 117 module.location = kCollapsePathList[i].test_case; | |
| 118 module_enumerator.CollapsePath(&module); | |
| 119 | |
| 120 SCOPED_TRACE("Test case no " + base::IntToString(i) + ": '" + | |
| 121 base::UTF16ToASCII(kCollapsePathList[i].expected_result) + | |
| 122 "'"); | |
| 123 EXPECT_EQ(kCollapsePathList[i].expected_result, module.location); | |
| 124 } | |
| 125 } | |
| OLD | NEW |