summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing/protocol_manager_helper_unittest.cc
blob: 39d26a8bd0b77cfee8ccdf4639f9747aa2011efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/strings/stringprintf.h"
#include "chrome/browser/safe_browsing/protocol_manager_helper.h"
#include "google_apis/google_api_keys.h"
#include "net/base/escape.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace safe_browsing {

class SafeBrowsingProtocolManagerHelperTest : public testing::Test {
 protected:
  std::string key_param_;

  void SetUp() override {
    std::string key = google_apis::GetAPIKey();
    if (!key.empty()) {
      key_param_ = base::StringPrintf("&key=%s",
          net::EscapeQueryParamValue(key, true).c_str());
    }
  }
};

TEST_F(SafeBrowsingProtocolManagerHelperTest, TestComposePver4Url) {
  std::string result = SafeBrowsingProtocolManagerHelper::ComposePver4Url(
      "a", "b", "c", "d", "e");
  EXPECT_EQ("a/b/c?alt=proto&client_id=d&client_version=e" + key_param_,
            result);
}

}  // namespace safe_browsing