| 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 namespace safe_browsing { |
| 22 |
| 21 class SafeBrowsingPingManagerTest : public testing::Test { | 23 class SafeBrowsingPingManagerTest : public testing::Test { |
| 22 protected: | 24 protected: |
| 23 std::string key_param_; | 25 std::string key_param_; |
| 24 | 26 |
| 25 void SetUp() override { | 27 void SetUp() override { |
| 26 std::string key = google_apis::GetAPIKey(); | 28 std::string key = google_apis::GetAPIKey(); |
| 27 if (!key.empty()) { | 29 if (!key.empty()) { |
| 28 key_param_ = base::StringPrintf( | 30 key_param_ = base::StringPrintf( |
| 29 "&key=%s", | 31 "&key=%s", |
| 30 net::EscapeQueryParamValue(key, true).c_str()); | 32 net::EscapeQueryParamValue(key, true).c_str()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 config.url_prefix = kUrlPrefix; | 108 config.url_prefix = kUrlPrefix; |
| 107 SafeBrowsingPingManager pm(NULL, config); | 109 SafeBrowsingPingManager pm(NULL, config); |
| 108 | 110 |
| 109 pm.version_ = kAppVer; | 111 pm.version_ = kAppVer; |
| 110 EXPECT_EQ( | 112 EXPECT_EQ( |
| 111 "https://prefix.com/foo/clientreport/malware?" | 113 "https://prefix.com/foo/clientreport/malware?" |
| 112 "client=unittest&appver=1.0&pver=1.0" + | 114 "client=unittest&appver=1.0&pver=1.0" + |
| 113 key_param_, | 115 key_param_, |
| 114 pm.ThreatDetailsUrl().spec()); | 116 pm.ThreatDetailsUrl().spec()); |
| 115 } | 117 } |
| 118 |
| 119 } // namespace safe_browsing |
| OLD | NEW |