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

Unified Diff: content/common/origin_trials/trial_token_validator_unittest.cc

Issue 1742053002: Move trial token code to content/common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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: content/common/origin_trials/trial_token_validator_unittest.cc
diff --git a/content/renderer/origin_trials/trial_token_validator_unittest.cc b/content/common/origin_trials/trial_token_validator_unittest.cc
similarity index 85%
rename from content/renderer/origin_trials/trial_token_validator_unittest.cc
rename to content/common/origin_trials/trial_token_validator_unittest.cc
index 858aa6f1566917a20b2fedf6dfc865ce67e7427b..9a2d27cf6a0a487c046b28cf00a512f5f7d3fee2 100644
--- a/content/renderer/origin_trials/trial_token_validator_unittest.cc
+++ b/content/common/origin_trials/trial_token_validator_unittest.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/renderer/origin_trials/trial_token_validator.h"
+#include "content/common/origin_trials/trial_token_validator.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/test/simple_test_clock.h"
#include "base/time/time.h"
-#include "content/public/renderer/content_renderer_client.h"
+#include "content/public/common/content_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -71,7 +71,7 @@ const char kExpiredToken[] =
const char kUnparsableToken[] = "abcde";
-class TestContentRendererClient : public content::ContentRendererClient {
+class TestContentClient : public ContentClient {
public:
base::StringPiece GetOriginTrialPublicKey() override {
return base::StringPiece(reinterpret_cast<const char*>(key_),
@@ -90,57 +90,58 @@ class TrialTokenValidatorTest : public testing::Test {
inappropriate_origin_(GURL(kInappropriateOrigin)),
insecure_origin_(GURL(kInsecureOrigin)) {
SetPublicKey(kTestPublicKey);
- SetRendererClientForTesting(&test_content_renderer_client_);
+ SetContentClient(&test_content_client_);
}
+ ~TrialTokenValidatorTest() override { SetContentClient(nullptr); }
+
void SetPublicKey(const uint8_t* key) {
- test_content_renderer_client_.SetOriginTrialPublicKey(key);
+ test_content_client_.SetOriginTrialPublicKey(key);
}
- TrialTokenValidator trial_token_validator_;
const url::Origin appropriate_origin_;
const url::Origin inappropriate_origin_;
const url::Origin insecure_origin_;
private:
- TestContentRendererClient test_content_renderer_client_;
+ TestContentClient test_content_client_;
};
TEST_F(TrialTokenValidatorTest, ValidateValidToken) {
- EXPECT_TRUE(trial_token_validator_.validateToken(
+ EXPECT_TRUE(TrialTokenValidator::ValidateToken(
kSampleToken, appropriate_origin_, kAppropriateFeatureName));
}
TEST_F(TrialTokenValidatorTest, ValidateInappropriateOrigin) {
- EXPECT_FALSE(TrialTokenValidator().validateToken(
+ EXPECT_FALSE(TrialTokenValidator::ValidateToken(
kSampleToken, inappropriate_origin_, kAppropriateFeatureName));
- EXPECT_FALSE(TrialTokenValidator().validateToken(
+ EXPECT_FALSE(TrialTokenValidator::ValidateToken(
kSampleToken, insecure_origin_, kAppropriateFeatureName));
}
TEST_F(TrialTokenValidatorTest, ValidateInappropriateFeature) {
- EXPECT_FALSE(TrialTokenValidator().validateToken(
+ EXPECT_FALSE(TrialTokenValidator::ValidateToken(
kSampleToken, appropriate_origin_, kInappropriateFeatureName));
}
TEST_F(TrialTokenValidatorTest, ValidateInvalidSignature) {
- EXPECT_FALSE(TrialTokenValidator().validateToken(
+ EXPECT_FALSE(TrialTokenValidator::ValidateToken(
kInvalidSignatureToken, appropriate_origin_, kAppropriateFeatureName));
}
TEST_F(TrialTokenValidatorTest, ValidateUnparsableToken) {
- EXPECT_FALSE(TrialTokenValidator().validateToken(
+ EXPECT_FALSE(TrialTokenValidator::ValidateToken(
kUnparsableToken, appropriate_origin_, kAppropriateFeatureName));
}
TEST_F(TrialTokenValidatorTest, ValidateExpiredToken) {
- EXPECT_FALSE(TrialTokenValidator().validateToken(
+ EXPECT_FALSE(TrialTokenValidator::ValidateToken(
kExpiredToken, appropriate_origin_, kAppropriateFeatureName));
}
TEST_F(TrialTokenValidatorTest, ValidateValidTokenWithIncorrectKey) {
SetPublicKey(kTestPublicKey2);
- EXPECT_FALSE(TrialTokenValidator().validateToken(
+ EXPECT_FALSE(TrialTokenValidator::ValidateToken(
kSampleToken, appropriate_origin_, kAppropriateFeatureName));
}

Powered by Google App Engine
This is Rietveld 408576698