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

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

Issue 254763005: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update url/BUILD.gn and address some style nits. Created 6 years, 7 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "content/public/browser/browser_context.h" 44 #include "content/public/browser/browser_context.h"
45 #include "content/public/test/test_browser_thread.h" 45 #include "content/public/test/test_browser_thread.h"
46 #include "net/base/load_flags.h" 46 #include "net/base/load_flags.h"
47 #include "net/base/net_log.h" 47 #include "net/base/net_log.h"
48 #include "net/dns/host_resolver.h" 48 #include "net/dns/host_resolver.h"
49 #include "net/test/python_utils.h" 49 #include "net/test/python_utils.h"
50 #include "net/url_request/url_fetcher.h" 50 #include "net/url_request/url_fetcher.h"
51 #include "net/url_request/url_fetcher_delegate.h" 51 #include "net/url_request/url_fetcher_delegate.h"
52 #include "net/url_request/url_request_status.h" 52 #include "net/url_request/url_request_status.h"
53 #include "testing/gtest/include/gtest/gtest.h" 53 #include "testing/gtest/include/gtest/gtest.h"
54 #include "url/url_constants.h"
54 55
55 using content::BrowserThread; 56 using content::BrowserThread;
56 57
57 namespace { 58 namespace {
58 59
59 const base::FilePath::CharType kDataFile[] = 60 const base::FilePath::CharType kDataFile[] =
60 FILE_PATH_LITERAL("testing_input_nomac.dat"); 61 FILE_PATH_LITERAL("testing_input_nomac.dat");
61 const char kUrlVerifyPath[] = "safebrowsing/verify_urls"; 62 const char kUrlVerifyPath[] = "safebrowsing/verify_urls";
62 const char kDBVerifyPath[] = "safebrowsing/verify_database"; 63 const char kDBVerifyPath[] = "safebrowsing/verify_database";
63 const char kTestCompletePath[] = "test_complete"; 64 const char kTestCompletePath[] = "test_complete";
(...skipping 20 matching lines...) Expand all
84 if (urls[i].empty()) 85 if (urls[i].empty())
85 continue; 86 continue;
86 PhishingUrl phishing_url; 87 PhishingUrl phishing_url;
87 std::vector<std::string> record_parts; 88 std::vector<std::string> record_parts;
88 base::SplitString(urls[i], '\t', &record_parts); 89 base::SplitString(urls[i], '\t', &record_parts);
89 if (record_parts.size() != 3) { 90 if (record_parts.size() != 3) {
90 LOG(ERROR) << "Unexpected URL format in phishing URL list: " 91 LOG(ERROR) << "Unexpected URL format in phishing URL list: "
91 << urls[i]; 92 << urls[i];
92 return false; 93 return false;
93 } 94 }
94 phishing_url.url = std::string(content::kHttpScheme) + 95 phishing_url.url = std::string(url::kHttpScheme) + "://" + record_parts[0];
95 "://" + record_parts[0];
96 phishing_url.list_name = record_parts[1]; 96 phishing_url.list_name = record_parts[1];
97 if (record_parts[2] == "yes") { 97 if (record_parts[2] == "yes") {
98 phishing_url.is_phishing = true; 98 phishing_url.is_phishing = true;
99 } else if (record_parts[2] == "no") { 99 } else if (record_parts[2] == "no") {
100 phishing_url.is_phishing = false; 100 phishing_url.is_phishing = false;
101 } else { 101 } else {
102 LOG(ERROR) << "Unrecognized expectation in " << urls[i] 102 LOG(ERROR) << "Unrecognized expectation in " << urls[i]
103 << ": " << record_parts[2]; 103 << ": " << record_parts[2];
104 return false; 104 return false;
105 } 105 }
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 safe_browsing_helper->FetchDBToVerify(test_server(), step)); 569 safe_browsing_helper->FetchDBToVerify(test_server(), step));
570 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); 570 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U);
571 last_step = step; 571 last_step = step;
572 } 572 }
573 573
574 // Verifies with server if test is done and waits till server responses. 574 // Verifies with server if test is done and waits till server responses.
575 EXPECT_EQ(net::URLRequestStatus::SUCCESS, 575 EXPECT_EQ(net::URLRequestStatus::SUCCESS,
576 safe_browsing_helper->VerifyTestComplete(test_server(), last_step)); 576 safe_browsing_helper->VerifyTestComplete(test_server(), last_step));
577 EXPECT_EQ("yes", safe_browsing_helper->response_data()); 577 EXPECT_EQ("yes", safe_browsing_helper->response_data());
578 } 578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698