features_unittest.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/ntp_snippets/features.h"
  5. #include <map>
  6. #include <string>
  7. #include "base/test/scoped_feature_list.h"
  8. #include "testing/gtest/include/gtest/gtest.h"
  9. #include "url/gurl.h"
  10. namespace ntp_snippets {
  11. namespace {
  12. const char kExpectedZineURL[] =
  13. "https://www.googleapis.com/auth/chrome-content-suggestions";
  14. const char kTestZineURL[] = "https://test.google.com/";
  15. } // namespace
  16. TEST(FeaturesTest, GetContentSuggestionsReferrerURL_DefaultValue) {
  17. base::test::ScopedFeatureList feature_list;
  18. feature_list.InitAndEnableFeature(kArticleSuggestionsFeature);
  19. EXPECT_EQ(kExpectedZineURL, GetContentSuggestionsReferrerURL());
  20. // In code this will be often used inside of a GURL.
  21. EXPECT_EQ(kExpectedZineURL, GURL(GetContentSuggestionsReferrerURL()));
  22. EXPECT_EQ(kExpectedZineURL, GURL(GetContentSuggestionsReferrerURL()).spec());
  23. }
  24. TEST(FeaturesTest, GetContentSuggestionsReferrerURL_ParamValue) {
  25. base::test::ScopedFeatureList feature_list;
  26. std::map<std::string, std::string> parameters;
  27. parameters["referrer_url"] = kTestZineURL;
  28. feature_list.InitAndEnableFeatureWithParameters(kArticleSuggestionsFeature,
  29. parameters);
  30. EXPECT_EQ(kTestZineURL, GetContentSuggestionsReferrerURL());
  31. }
  32. } // namespace ntp_snippets