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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_test.cc

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This test uses the safebrowsing test server published at 5 // This test uses the safebrowsing test server published at
6 // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing 6 // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing
7 // protocol implemetation. Details of the safebrowsing testing flow is 7 // protocol implemetation. Details of the safebrowsing testing flow is
8 // documented at 8 // documented at
9 // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting 9 // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting
10 // 10 //
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // Parses server response for verify_urls. The expected format is: 76 // Parses server response for verify_urls. The expected format is:
77 // 77 //
78 // first.random.url.com/ internal-test-shavar yes 78 // first.random.url.com/ internal-test-shavar yes
79 // second.random.url.com/ internal-test-shavar yes 79 // second.random.url.com/ internal-test-shavar yes
80 // ... 80 // ...
81 bool ParsePhishingUrls(const std::string& data, 81 bool ParsePhishingUrls(const std::string& data,
82 std::vector<PhishingUrl>* phishing_urls) { 82 std::vector<PhishingUrl>* phishing_urls) {
83 if (data.empty()) 83 if (data.empty())
84 return false; 84 return false;
85 85
86 std::vector<std::string> urls; 86 for (const base::StringPiece& url_str : base::SplitStringPiece(
87 base::SplitString(data, '\n', &urls); 87 data, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
88 for (size_t i = 0; i < urls.size(); ++i) {
89 if (urls[i].empty())
90 continue;
91 PhishingUrl phishing_url; 88 PhishingUrl phishing_url;
92 std::vector<std::string> record_parts; 89 std::vector<std::string> record_parts = base::SplitString(
93 base::SplitString(urls[i], '\t', &record_parts); 90 url_str, "\t", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
94 if (record_parts.size() != 3) { 91 if (record_parts.size() != 3) {
95 LOG(ERROR) << "Unexpected URL format in phishing URL list: " 92 LOG(ERROR) << "Unexpected URL format in phishing URL list: "
96 << urls[i]; 93 << url_str.as_string();
97 return false; 94 return false;
98 } 95 }
99 phishing_url.url = std::string(url::kHttpScheme) + "://" + record_parts[0]; 96 phishing_url.url = std::string(url::kHttpScheme) + "://" + record_parts[0];
100 phishing_url.list_name = record_parts[1]; 97 phishing_url.list_name = record_parts[1];
101 if (record_parts[2] == "yes") { 98 if (record_parts[2] == "yes") {
102 phishing_url.is_phishing = true; 99 phishing_url.is_phishing = true;
103 } else if (record_parts[2] == "no") { 100 } else if (record_parts[2] == "no") {
104 phishing_url.is_phishing = false; 101 phishing_url.is_phishing = false;
105 } else { 102 } else {
106 LOG(ERROR) << "Unrecognized expectation in " << urls[i] 103 LOG(ERROR) << "Unrecognized expectation in " << url_str.as_string()
107 << ": " << record_parts[2]; 104 << ": " << record_parts[2];
108 return false; 105 return false;
109 } 106 }
110 phishing_urls->push_back(phishing_url); 107 phishing_urls->push_back(phishing_url);
111 } 108 }
112 return true; 109 return true;
113 } 110 }
114 111
115 class FakeSafeBrowsingService : public SafeBrowsingService { 112 class FakeSafeBrowsingService : public SafeBrowsingService {
116 public: 113 public:
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 safe_browsing_helper->FetchDBToVerify(test_server(), step)); 574 safe_browsing_helper->FetchDBToVerify(test_server(), step));
578 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); 575 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U);
579 last_step = step; 576 last_step = step;
580 } 577 }
581 578
582 // Verifies with server if test is done and waits till server responses. 579 // Verifies with server if test is done and waits till server responses.
583 EXPECT_EQ(net::URLRequestStatus::SUCCESS, 580 EXPECT_EQ(net::URLRequestStatus::SUCCESS,
584 safe_browsing_helper->VerifyTestComplete(test_server(), last_step)); 581 safe_browsing_helper->VerifyTestComplete(test_server(), last_step));
585 EXPECT_EQ("yes", safe_browsing_helper->response_data()); 582 EXPECT_EQ("yes", safe_browsing_helper->response_data());
586 } 583 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/chunk_range.cc ('k') | chrome/browser/spellchecker/spellcheck_custom_dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698