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

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher_unittest.cc

Issue 2292053004: Inject API key directly into snippets fetcher. (Closed)
Patch Set: rebase Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/ntp_snippets_fetcher_unittest.cc
diff --git a/components/ntp_snippets/ntp_snippets_fetcher_unittest.cc b/components/ntp_snippets/ntp_snippets_fetcher_unittest.cc
index c83dec199d6cb8fcde6fd748973345e047024e53..07fb31c302d48ff48b329d910f011612db81e158 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher_unittest.cc
+++ b/components/ntp_snippets/ntp_snippets_fetcher_unittest.cc
@@ -25,7 +25,6 @@
#include "components/signin/core/browser/test_signin_client.h"
#include "components/variations/entropy_provider.h"
#include "components/variations/variations_associated_data.h"
-#include "google_apis/google_api_keys.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -47,11 +46,12 @@ using testing::SizeIs;
using testing::StartsWith;
using testing::WithArg;
-const char kTestChromeReaderUrlFormat[] =
- "https://chromereader-pa.googleapis.com/v1/fetch?key=%s";
-const char kTestChromeContentSuggestionsUrlFormat[] =
+const char kAPIKey[] = "fakeAPIkey";
+const char kTestChromeReaderUrl[] =
+ "https://chromereader-pa.googleapis.com/v1/fetch?key=fakeAPIkey";
+const char kTestChromeContentSuggestionsUrl[] =
"https://chromecontentsuggestions-pa.googleapis.com/v1/suggestions/"
- "fetch?key=%s";
+ "fetch?key=fakeAPIkey";
// Artificial time delay for JSON parsing.
const int64_t kTestJsonParsingLatencyMs = 20;
@@ -138,16 +138,12 @@ void ParseJsonDelayed(
base::TimeDelta::FromMilliseconds(kTestJsonParsingLatencyMs));
}
-GURL GetFetcherUrl(const char* url_format) {
- return GURL(base::StringPrintf(url_format, google_apis::GetAPIKey().c_str()));
-}
-
} // namespace
class NTPSnippetsFetcherTest : public testing::Test {
public:
NTPSnippetsFetcherTest()
- : NTPSnippetsFetcherTest(GetFetcherUrl(kTestChromeReaderUrlFormat),
+ : NTPSnippetsFetcherTest(GURL(kTestChromeReaderUrl),
std::map<std::string, std::string>()) {}
NTPSnippetsFetcherTest(const GURL& gurl,
@@ -170,7 +166,7 @@ class NTPSnippetsFetcherTest : public testing::Test {
scoped_refptr<net::TestURLRequestContextGetter>(
new net::TestURLRequestContextGetter(mock_task_runner_.get())),
pref_service_.get(), &category_factory_, base::Bind(&ParseJsonDelayed),
- /*is_stable_channel=*/true);
+ kAPIKey);
snippets_fetcher_->SetCallback(
base::Bind(&MockSnippetsAvailableCallback::WrappedRun,
@@ -239,14 +235,14 @@ class NTPSnippetsContentSuggestionsFetcherTest : public NTPSnippetsFetcherTest {
public:
NTPSnippetsContentSuggestionsFetcherTest()
: NTPSnippetsFetcherTest(
- GetFetcherUrl(kTestChromeContentSuggestionsUrlFormat),
+ GURL(kTestChromeContentSuggestionsUrl),
{{"content_suggestions_backend", kContentSuggestionsServer}}) {}
};
class NTPSnippetsFetcherHostRestrictedTest : public NTPSnippetsFetcherTest {
public:
NTPSnippetsFetcherHostRestrictedTest()
- : NTPSnippetsFetcherTest(GetFetcherUrl(kTestChromeReaderUrlFormat),
+ : NTPSnippetsFetcherTest(GURL(kTestChromeReaderUrl),
{{"fetching_host_restrict", "on"}}) {}
};
« no previous file with comments | « components/ntp_snippets/ntp_snippets_fetcher.cc ('k') | components/ntp_snippets/ntp_snippets_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698