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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/environment_data_collection_win_unittest.cc

Issue 2950803002: Use ContainsValue() instead of std::find() in chrome/browser/ and chrome/test/ (Closed)
Patch Set: Reverted code for file thumbnail_cache.cc Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/safe_browsing/incident_reporting/environment_data_colle ction_win.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/environment_data_colle ction_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm>
11 #include <string> 10 #include <string>
12 11
13 #include "base/base_paths.h" 12 #include "base/base_paths.h"
14 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
15 #include "base/path_service.h" 14 #include "base/path_service.h"
16 #include "base/scoped_native_library.h" 15 #include "base/scoped_native_library.h"
16 #include "base/stl_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/test/test_reg_util_win.h" 18 #include "base/test/test_reg_util_win.h"
19 #include "base/win/registry.h" 19 #include "base/win/registry.h"
20 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_unitt est_util_win.h" 20 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_unitt est_util_win.h"
21 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_verif ier_win.h" 21 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_verif ier_win.h"
22 #include "chrome/browser/safe_browsing/path_sanitizer.h" 22 #include "chrome/browser/safe_browsing/path_sanitizer.h"
23 #include "chrome_elf/chrome_elf_constants.h" 23 #include "chrome_elf/chrome_elf_constants.h"
24 #include "components/safe_browsing/csd.pb.h" 24 #include "components/safe_browsing/csd.pb.h"
25 #include "net/base/winsock_init.h" 25 #include "net/base/winsock_init.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 17 matching lines...) Expand all
44 return false; 44 return false;
45 } 45 }
46 46
47 // Look through dll entries and check for the presence of the LSP feature for 47 // Look through dll entries and check for the presence of the LSP feature for
48 // |dll_path|. 48 // |dll_path|.
49 bool DllEntryContainsLspFeature( 49 bool DllEntryContainsLspFeature(
50 const ClientIncidentReport_EnvironmentData_Process& process_report, 50 const ClientIncidentReport_EnvironmentData_Process& process_report,
51 const std::string& dll_path) { 51 const std::string& dll_path) {
52 for (const auto& dll : process_report.dll()) { 52 for (const auto& dll : process_report.dll()) {
53 if (dll.path() == dll_path && 53 if (dll.path() == dll_path &&
54 std::find(dll.feature().begin(), dll.feature().end(), 54 base::ContainsValue(
55 ClientIncidentReport_EnvironmentData_Process_Dll::LSP) != 55 dll.feature(),
56 dll.feature().end()) { 56 ClientIncidentReport_EnvironmentData_Process_Dll::LSP)) {
57 // LSP feature found. 57 // LSP feature found.
58 return true; 58 return true;
59 } 59 }
60 } 60 }
61
62 return false; 61 return false;
63 } 62 }
64 63
65 } // namespace 64 } // namespace
66 65
67 TEST(SafeBrowsingEnvironmentDataCollectionWinTest, CollectDlls) { 66 TEST(SafeBrowsingEnvironmentDataCollectionWinTest, CollectDlls) {
68 // This test will check if the CollectDlls method works by loading 67 // This test will check if the CollectDlls method works by loading
69 // a dll and then checking if we can find it within the process report. 68 // a dll and then checking if we can find it within the process report.
70 // Pick msvidc32.dll as it is present from WinXP to Win8 and yet rarely used. 69 // Pick msvidc32.dll as it is present from WinXP to Win8 and yet rarely used.
71 // msvidc32.dll exists in both 32 and 64 bit versions. 70 // msvidc32.dll exists in both 32 and 64 bit versions.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 TEST(SafeBrowsingEnvironmentDataCollectionWinTest, 262 TEST(SafeBrowsingEnvironmentDataCollectionWinTest,
264 CollectDomainEnrollmentData) { 263 CollectDomainEnrollmentData) {
265 // The test may or may not be running on a domain-enrolled machine, so all we 264 // The test may or may not be running on a domain-enrolled machine, so all we
266 // can check is that some value is filled in. 265 // can check is that some value is filled in.
267 ClientIncidentReport_EnvironmentData_OS os_data; 266 ClientIncidentReport_EnvironmentData_OS os_data;
268 CollectDomainEnrollmentData(&os_data); 267 CollectDomainEnrollmentData(&os_data);
269 EXPECT_TRUE(os_data.has_is_enrolled_to_domain()); 268 EXPECT_TRUE(os_data.has_is_enrolled_to_domain());
270 } 269 }
271 270
272 } // namespace safe_browsing 271 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698