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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/test/scoped_task_scheduler.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 typedef testing::Test EnumerateModulesTest; | 16 typedef testing::Test EnumerateModulesTest; |
16 | 17 |
17 // Set up some constants to use as default when creating the structs. | 18 // Set up some constants to use as default when creating the structs. |
18 static const ModuleEnumerator::ModuleType kType = | 19 static const ModuleEnumerator::ModuleType kType = |
19 ModuleEnumerator::LOADED_MODULE; | 20 ModuleEnumerator::LOADED_MODULE; |
20 | 21 |
21 static const ModuleEnumerator::ModuleStatus kStatus = | 22 static const ModuleEnumerator::ModuleStatus kStatus = |
22 ModuleEnumerator::NOT_MATCHED; | 23 ModuleEnumerator::NOT_MATCHED; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } kCollapsePathList[] = { | 97 } kCollapsePathList[] = { |
97 // Negative testing (should not collapse this path). | 98 // Negative testing (should not collapse this path). |
98 { base::ASCIIToUTF16("c:\\a\\a.dll"), base::ASCIIToUTF16("c:\\a\\a.dll") }, | 99 { base::ASCIIToUTF16("c:\\a\\a.dll"), base::ASCIIToUTF16("c:\\a\\a.dll") }, |
99 // These two are to test that we select the maximum collapsed path. | 100 // These two are to test that we select the maximum collapsed path. |
100 { base::ASCIIToUTF16("%foo%\\a.dll"), base::ASCIIToUTF16("c:\\foo\\a.dll") }, | 101 { base::ASCIIToUTF16("%foo%\\a.dll"), base::ASCIIToUTF16("c:\\foo\\a.dll") }, |
101 { base::ASCIIToUTF16("%x%\\a.dll"), | 102 { base::ASCIIToUTF16("%x%\\a.dll"), |
102 base::ASCIIToUTF16("c:\\foo\\bar\\a.dll") }, | 103 base::ASCIIToUTF16("c:\\foo\\bar\\a.dll") }, |
103 }; | 104 }; |
104 | 105 |
105 TEST_F(EnumerateModulesTest, CollapsePath) { | 106 TEST_F(EnumerateModulesTest, CollapsePath) { |
| 107 base::test::ScopedTaskScheduler scoped_task_scheduler; |
106 ModuleEnumerator module_enumerator(nullptr); | 108 ModuleEnumerator module_enumerator(nullptr); |
107 module_enumerator.path_mapping_.clear(); | 109 module_enumerator.path_mapping_.clear(); |
108 module_enumerator.path_mapping_.push_back( | 110 module_enumerator.path_mapping_.push_back( |
109 std::make_pair(L"c:\\foo\\", L"%foo%")); | 111 std::make_pair(L"c:\\foo\\", L"%foo%")); |
110 module_enumerator.path_mapping_.push_back( | 112 module_enumerator.path_mapping_.push_back( |
111 std::make_pair(L"c:\\foo\\bar\\", L"%x%")); | 113 std::make_pair(L"c:\\foo\\bar\\", L"%x%")); |
112 | 114 |
113 for (size_t i = 0; i < arraysize(kCollapsePathList); ++i) { | 115 for (size_t i = 0; i < arraysize(kCollapsePathList); ++i) { |
114 ModuleEnumerator::Module module; | 116 ModuleEnumerator::Module module; |
115 module.location = kCollapsePathList[i].test_case; | 117 module.location = kCollapsePathList[i].test_case; |
116 module_enumerator.CollapsePath(&module); | 118 module_enumerator.CollapsePath(&module); |
117 | 119 |
118 SCOPED_TRACE("Test case no " + base::IntToString(i) + ": '" + | 120 SCOPED_TRACE("Test case no " + base::IntToString(i) + ": '" + |
119 base::UTF16ToASCII(kCollapsePathList[i].expected_result) + | 121 base::UTF16ToASCII(kCollapsePathList[i].expected_result) + |
120 "'"); | 122 "'"); |
121 EXPECT_EQ(kCollapsePathList[i].expected_result, module.location); | 123 EXPECT_EQ(kCollapsePathList[i].expected_result, module.location); |
122 } | 124 } |
123 } | 125 } |
OLD | NEW |