chromium/chrome/browser/chrome_origin_trials_browsertest.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <bitset>
#include <string_view>
#include <vector>

#include "base/base64.h"
#include "base/command_line.h"
#include "base/ranges/algorithm.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/embedder_support/origin_trials/pref_names.h"
#include "components/embedder_support/switches.h"
#include "components/prefs/pref_service.h"
#include "content/public/common/content_client.h"
#include "content/public/test/browser_test.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/origin_trials/origin_trial_policy.h"

namespace {

struct DisabledItemsTestData {};

static const char kNewPublicKey[] =;

const DisabledItemsTestData kDisabledFeaturesTests[] =;

const uint8_t kTokenSignatureSize =;

struct DisabledTokensTestData {};

// Token 1
// generate_token.py http://localhost Feature1 --expire-timestamp=2000000000
const char kToken1Encoded[] =;
const uint8_t kToken1Signature[kTokenSignatureSize] =;

// Token 2
// generate_token.py http://localhost Feature2 --expire-timestamp=2000000000
const char kToken2Encoded[] =;
const uint8_t kToken2Signature[kTokenSignatureSize] =;

const DisabledTokensTestData kDisabledTokensTests[] =;

class ChromeOriginTrialsTest : public InProcessBrowserTest {};

// Tests to verify that the command line is not set, when no prefs exist for
// the various updates.

IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsTest, NoPublicKeySet) {}

IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsTest, NoDisabledFeatures) {}

IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsTest, NoDisabledTokens) {}

// Tests to verify that the public key is correctly read from prefs and
// added to the command line
IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsTest, PRE_PublicKeySetOnCommandLine) {}

IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsTest, PublicKeySetOnCommandLine) {}

// Tests to verify that disabled features are correctly read from prefs and
// added to the command line
class ChromeOriginTrialsDisabledFeaturesTest
    : public ChromeOriginTrialsTest,
      public ::testing::WithParamInterface<DisabledItemsTestData> {};

IN_PROC_BROWSER_TEST_P(ChromeOriginTrialsDisabledFeaturesTest,
                       PRE_DisabledFeaturesSetOnCommandLine) {}

IN_PROC_BROWSER_TEST_P(ChromeOriginTrialsDisabledFeaturesTest,
                       DisabledFeaturesSetOnCommandLine) {}

INSTANTIATE_TEST_SUITE_P();

// Tests to verify that disabled tokens are correctly read from prefs and
// added to the OriginTrialPolicy.
class ChromeOriginTrialsDisabledTokensTest
    : public ChromeOriginTrialsTest,
      public ::testing::WithParamInterface<DisabledTokensTestData> {};

IN_PROC_BROWSER_TEST_P(ChromeOriginTrialsDisabledTokensTest,
                       PRE_DisabledTokensInPolicy) {}

IN_PROC_BROWSER_TEST_P(ChromeOriginTrialsDisabledTokensTest,
                       DisabledTokensInPolicy) {}

INSTANTIATE_TEST_SUITE_P();

// Should match kMaxDisabledTokens in
// components/embedder_support/origin_trials/origin_trials_settings_storage.cc
const uint16_t kMaxTokensToProduce =;
const uint16_t kAboveMaxTokensToProduce =;

// Tests to verify the behavior of the policy once the number of disabled tokens
// provided exceeds the limit.

class ChromeOriginTrialsDisabledTokensLimitTest
    : public ChromeOriginTrialsTest {};  // namespace

IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsDisabledTokensLimitTest,
                       PRE_DisabledTokensMaxTokensAppliedToPolicy) {}

IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsDisabledTokensLimitTest,
                       DisabledTokensMaxTokensAppliedToPolicy) {}

IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsDisabledTokensLimitTest,
                       PRE_DisabledTokensOverSizeLimitAreIgnored) {}

IN_PROC_BROWSER_TEST_F(ChromeOriginTrialsDisabledTokensLimitTest,
                       DisabledTokensOverSizeLimitAreIgnored) {}

}  // namespace