OLD | NEW |
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 | 5 |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "chrome/browser/safe_browsing/ping_manager.h" | 9 #include "chrome/browser/safe_browsing/ping_manager.h" |
10 #include "google_apis/google_api_keys.h" | 10 #include "google_apis/google_api_keys.h" |
11 #include "net/base/escape.h" | 11 #include "net/base/escape.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 using base::Time; | 14 using base::Time; |
15 using base::TimeDelta; | 15 using base::TimeDelta; |
16 | 16 |
17 static const char kUrlPrefix[] = "https://prefix.com/foo"; | 17 static const char kUrlPrefix[] = "https://prefix.com/foo"; |
18 static const char kClient[] = "unittest"; | 18 static const char kClient[] = "unittest"; |
19 static const char kAppVer[] = "1.0"; | 19 static const char kAppVer[] = "1.0"; |
20 | 20 |
21 class SafeBrowsingPingManagerTest : public testing::Test { | 21 class SafeBrowsingPingManagerTest : public testing::Test { |
22 protected: | 22 protected: |
23 std::string key_param_; | 23 std::string key_param_; |
24 | 24 |
25 virtual void SetUp() { | 25 void SetUp() override { |
26 std::string key = google_apis::GetAPIKey(); | 26 std::string key = google_apis::GetAPIKey(); |
27 if (!key.empty()) { | 27 if (!key.empty()) { |
28 key_param_ = base::StringPrintf( | 28 key_param_ = base::StringPrintf( |
29 "&key=%s", | 29 "&key=%s", |
30 net::EscapeQueryParamValue(key, true).c_str()); | 30 net::EscapeQueryParamValue(key, true).c_str()); |
31 } | 31 } |
32 } | 32 } |
33 }; | 33 }; |
34 | 34 |
35 TEST_F(SafeBrowsingPingManagerTest, TestSafeBrowsingHitUrl) { | 35 TEST_F(SafeBrowsingPingManagerTest, TestSafeBrowsingHitUrl) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 SafeBrowsingProtocolConfig config; | 93 SafeBrowsingProtocolConfig config; |
94 config.client_name = kClient; | 94 config.client_name = kClient; |
95 config.url_prefix = kUrlPrefix; | 95 config.url_prefix = kUrlPrefix; |
96 SafeBrowsingPingManager pm(NULL, config); | 96 SafeBrowsingPingManager pm(NULL, config); |
97 | 97 |
98 pm.version_ = kAppVer; | 98 pm.version_ = kAppVer; |
99 EXPECT_EQ("https://prefix.com/foo/clientreport/malware?" | 99 EXPECT_EQ("https://prefix.com/foo/clientreport/malware?" |
100 "client=unittest&appver=1.0&pver=1.0" + key_param_, | 100 "client=unittest&appver=1.0&pver=1.0" + key_param_, |
101 pm.MalwareDetailsUrl().spec()); | 101 pm.MalwareDetailsUrl().spec()); |
102 } | 102 } |
OLD | NEW |