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

Unified Diff: components/ntp_snippets/ntp_snippets_service_unittest.cc

Issue 2292053004: Inject API key directly into snippets fetcher. (Closed)
Patch Set: rebase Created 4 years, 4 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_service_unittest.cc
diff --git a/components/ntp_snippets/ntp_snippets_service_unittest.cc b/components/ntp_snippets/ntp_snippets_service_unittest.cc
index fd7814d955ff092796f162f98e0a8416dc87de2f..13f19195d0affc323b550c14bebed8784249ec43 100644
--- a/components/ntp_snippets/ntp_snippets_service_unittest.cc
+++ b/components/ntp_snippets/ntp_snippets_service_unittest.cc
@@ -37,7 +37,6 @@
#include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
#include "components/signin/core/browser/fake_signin_manager.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"
@@ -74,9 +73,10 @@ const base::Time::Exploded kDefaultCreationTime = {2015, 11, 4, 25, 13, 46, 45};
const char kTestContentSuggestionsServerEndpoint[] =
"https://localunittest-chromecontentsuggestions-pa.googleapis.com/v1/"
"suggestions/fetch";
-const char kTestContentSuggestionsServerFormat[] =
+const char kAPIKey[] = "fakeAPIkey";
+const char kTestContentSuggestionsServerWithAPIKey[] =
"https://localunittest-chromecontentsuggestions-pa.googleapis.com/v1/"
- "suggestions/fetch?key=%s";
+ "suggestions/fetch?key=fakeAPIkey";
const char kSnippetUrl[] = "http://localhost/foobar";
const char kSnippetTitle[] = "Title";
@@ -315,8 +315,7 @@ class NTPSnippetsServiceTest : public ::testing::Test {
kTestContentSuggestionsServerEndpoint}}),
fake_url_fetcher_factory_(
/*default_factory=*/&failing_url_fetcher_factory_),
- test_url_(base::StringPrintf(kTestContentSuggestionsServerFormat,
- google_apis::GetAPIKey().c_str())),
+ test_url_(kTestContentSuggestionsServerWithAPIKey),
observer_(base::MakeUnique<FakeContentSuggestionsProviderObserver>()) {
NTPSnippetsService::RegisterProfilePrefs(utils_.pref_service()->registry());
@@ -350,7 +349,7 @@ class NTPSnippetsServiceTest : public ::testing::Test {
utils_.fake_signin_manager(), fake_token_service_.get(),
std::move(request_context_getter), utils_.pref_service(),
&category_factory_, base::Bind(&ParseJson),
- /*is_stable_channel=*/true);
+ kAPIKey);
utils_.fake_signin_manager()->SignIn("foo@bar.com");
snippets_fetcher->SetPersonalizationForTesting(

Powered by Google App Engine
This is Rietveld 408576698