| OLD | NEW |
| 1 // Copyright (c) 2010 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 "base/string_number_conversions.h" | 5 #include "base/string_number_conversions.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/enumerate_modules_model_win.h" | 8 #include "chrome/browser/enumerate_modules_model_win.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 typedef public testing::Test EnumerateModulesTest; | 11 typedef public testing::Test EnumerateModulesTest; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 EXPECT_STREQ(expected.version.c_str(), test.version.c_str()); | 71 EXPECT_STREQ(expected.version.c_str(), test.version.c_str()); |
| 72 EXPECT_STREQ(expected.digital_signer.c_str(), test.digital_signer.c_str()); | 72 EXPECT_STREQ(expected.digital_signer.c_str(), test.digital_signer.c_str()); |
| 73 EXPECT_EQ(expected.recommended_action, test.recommended_action); | 73 EXPECT_EQ(expected.recommended_action, test.recommended_action); |
| 74 EXPECT_TRUE(test.normalized); | 74 EXPECT_TRUE(test.normalized); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 const ModuleEnumerator::Module kStandardModule = | 78 const ModuleEnumerator::Module kStandardModule = |
| 79 { kType, kStatus, L"c:\\foo\\bar.dll", L"", L"Prod", L"Desc", L"1.0", L"Sig", | 79 { kType, kStatus, L"c:\\foo\\bar.dll", L"", L"Prod", L"Desc", L"1.0", L"Sig", |
| 80 ModuleEnumerator::NONE }; | 80 ModuleEnumerator::NONE }; |
| 81 const ModuleEnumerator::Module kStandardModuleNoDescription = |
| 82 { kType, kStatus, L"c:\\foo\\bar.dll", L"", L"Prod", L"", L"1.0", L"Sig", |
| 83 ModuleEnumerator::NONE }; |
| 84 const ModuleEnumerator::Module kStandardModuleNoSignature = |
| 85 { kType, kStatus, L"c:\\foo\\bar.dll", L"", L"Prod", L"Desc", L"1.0", L"", |
| 86 ModuleEnumerator::NONE }; |
| 81 | 87 |
| 82 // Name, location, description and signature are compared by hashing. | 88 // Name, location, description and signature are compared by hashing. |
| 83 static const char kMatchName[] = "88e8c9e0"; // "bar.dll". | 89 static const char kMatchName[] = "88e8c9e0"; // "bar.dll". |
| 84 static const char kNoMatchName[] = "barfoo.dll"; | 90 static const char kNoMatchName[] = "barfoo.dll"; |
| 85 static const char kMatchLocation[] = "e6ca7b1c"; // "c:\\foo\\". | 91 static const char kMatchLocation[] = "e6ca7b1c"; // "c:\\foo\\". |
| 86 static const char kNoMatchLocation[] = "c:\\foobar\\"; | 92 static const char kNoMatchLocation[] = "c:\\foobar\\"; |
| 87 static const char kMatchDesc[] = "5c4419a6"; // "Desc". | 93 static const char kMatchDesc[] = "5c4419a6"; // "Desc". |
| 88 static const char kNoMatchDesc[] = "NoDesc"; | 94 static const char kNoMatchDesc[] = "NoDesc"; |
| 89 static const char kVersionHigh[] = "2.0"; | 95 static const char kVersionHigh[] = "2.0"; |
| 90 static const char kVersionLow[] = "0.5"; | 96 static const char kVersionLow[] = "0.5"; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 113 }, { // Matches: Name, not version (location not given) => Not a match. | 119 }, { // Matches: Name, not version (location not given) => Not a match. |
| 114 ModuleEnumerator::NOT_MATCHED, | 120 ModuleEnumerator::NOT_MATCHED, |
| 115 kStandardModule, | 121 kStandardModule, |
| 116 { kMatchName, kEmpty, kEmpty, kVersionHigh, kVersionHigh, | 122 { kMatchName, kEmpty, kEmpty, kVersionHigh, kVersionHigh, |
| 117 ModuleEnumerator::SEE_LINK } | 123 ModuleEnumerator::SEE_LINK } |
| 118 }, { // Matches: Name, location => Suspected match. | 124 }, { // Matches: Name, location => Suspected match. |
| 119 ModuleEnumerator::SUSPECTED_BAD, | 125 ModuleEnumerator::SUSPECTED_BAD, |
| 120 kStandardModule, | 126 kStandardModule, |
| 121 { kMatchName, kMatchLocation, kEmpty, kEmpty, kEmpty, | 127 { kMatchName, kMatchLocation, kEmpty, kEmpty, kEmpty, |
| 122 ModuleEnumerator::SEE_LINK } | 128 ModuleEnumerator::SEE_LINK } |
| 129 }, { // Matches: Name, location, (description not given) => Confirmed match. |
| 130 ModuleEnumerator::CONFIRMED_BAD, |
| 131 kStandardModuleNoDescription, // Note: No description. |
| 132 { kMatchName, kMatchLocation, kEmpty, kEmpty, kEmpty, |
| 133 ModuleEnumerator::SEE_LINK } |
| 134 }, { // Matches: Name, location, (signature not given) => Confirmed match. |
| 135 ModuleEnumerator::CONFIRMED_BAD, |
| 136 kStandardModuleNoSignature, // Note: No signature. |
| 137 { kMatchName, kMatchLocation, kEmpty, kEmpty, kEmpty, |
| 138 ModuleEnumerator::SEE_LINK } |
| 123 }, { // Matches: Name, location (not version) => Not a match. | 139 }, { // Matches: Name, location (not version) => Not a match. |
| 124 ModuleEnumerator::NOT_MATCHED, | 140 ModuleEnumerator::NOT_MATCHED, |
| 125 kStandardModule, | 141 kStandardModule, |
| 126 { kMatchName, kMatchLocation, kEmpty, kVersionHigh, kVersionLow, | 142 { kMatchName, kMatchLocation, kEmpty, kVersionHigh, kVersionLow, |
| 127 ModuleEnumerator::SEE_LINK } | 143 ModuleEnumerator::SEE_LINK } |
| 128 }, { // Matches: Name, location, signature => Confirmed match. | 144 }, { // Matches: Name, location, signature => Confirmed match. |
| 129 ModuleEnumerator::CONFIRMED_BAD, | 145 ModuleEnumerator::CONFIRMED_BAD, |
| 130 kStandardModule, | 146 kStandardModule, |
| 131 { kMatchName, kMatchLocation, kMatchSignature, kEmpty, kEmpty, | 147 { kMatchName, kMatchLocation, kMatchSignature, kEmpty, kEmpty, |
| 132 ModuleEnumerator::SEE_LINK } | 148 ModuleEnumerator::SEE_LINK } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 ModuleEnumerator::Module module; | 230 ModuleEnumerator::Module module; |
| 215 module.location = kCollapsePathList[i].test_case; | 231 module.location = kCollapsePathList[i].test_case; |
| 216 module_enumerator->CollapsePath(&module); | 232 module_enumerator->CollapsePath(&module); |
| 217 | 233 |
| 218 SCOPED_TRACE("Test case no " + base::IntToString(i) + | 234 SCOPED_TRACE("Test case no " + base::IntToString(i) + |
| 219 ": '" + UTF16ToASCII(kCollapsePathList[i].expected_result) + | 235 ": '" + UTF16ToASCII(kCollapsePathList[i].expected_result) + |
| 220 "'"); | 236 "'"); |
| 221 EXPECT_EQ(kCollapsePathList[i].expected_result, module.location); | 237 EXPECT_EQ(kCollapsePathList[i].expected_result, module.location); |
| 222 } | 238 } |
| 223 } | 239 } |
| OLD | NEW |