chromium/net/cookies/canonical_cookie_test_helpers.h

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

#ifndef NET_COOKIES_CANONICAL_COOKIE_TEST_HELPERS_H_
#define NET_COOKIES_CANONICAL_COOKIE_TEST_HELPERS_H_

#include <string>
#include <utility>
#include <vector>

#include "base/strings/string_split.h"
#include "net/cookies/canonical_cookie.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace net {

MATCHER_P(MatchesCookieLine, cookie_line, "") {}

// Matches a CanonicalCookie with the given name.
MATCHER_P(MatchesCookieWithName, name, "") {}

MATCHER_P2(MatchesCookieNameValue, name, value, "") {}

MATCHER_P2(MatchesCookieWithNameSourceType, name, source_type, "") {}

MATCHER_P(MatchesCookieAccessWithName, name, "") {}

// Splits a string into key-value pairs, and executes the provided matcher on
// the result.
MATCHER_P3(WhenKVSplit, pair_delim, kv_delim, inner_matcher, "") {}

// Executes the inner_matcher on the Cookie string arg after it's transformed
// into a vector.
// If the arg is a ';'-delimited string of Cookie 'name=value' or 'name' pairs,
// then the matcher will execute on a vector of <name, value> pairs.
// If the arg can't be split into these pairs then the inner_matcher will
// execute on an empty vector.
MATCHER_P(CookieStringIs, inner_matcher, "") {}

MATCHER_P2(MatchesCookieWithAccessResult, cookie, access_result, "") {}

// Helper for checking that status.IsInclude() == true.
MATCHER(IsInclude, "") {}

// Helper for checking that status.HasSchemefulDowngradeWarning() == true.
MATCHER(HasSchemefulDowngradeWarning, "") {}

// Helper for checking that status.HasWarningReason(reason) == true.
MATCHER_P(HasWarningReason, reason, "") {}

// Helper for checking that status.HasExclusionReason(reason) == true.
MATCHER_P(HasExclusionReason, reason, "") {}

// Helper for checking that status.exemption_reason() == reason.
MATCHER_P(HasExactlyExemptionReason, reason, "") {}

// Helper for checking that status.HasExactlyExclusionReasonsForTesting(reasons)
// == true.
MATCHER_P(HasExactlyExclusionReasonsForTesting, reasons, "") {}

// Helper for checking that status.HasExactlyWarningReasonsForTesting(reasons)
// == true.
MATCHER_P(HasExactlyWarningReasonsForTesting, reasons, "") {}

MATCHER(ShouldWarn, "") {}

// Helper for checking CookieAccessResults. Should be called with matchers (or
// values) for each of the fields of a CookieAccessResult.
MATCHER_P4(MatchesCookieAccessResult,
           status,
           effective_same_site,
           access_semantics,
           is_allowed_to_access_secure_cookies,
           "") {}

MATCHER_P3(MatchesCookieAndLineWithAccessResult,
           cookie,
           line,
           access_result,
           "") {}

MATCHER(NameIs, "") {}

MATCHER(CanonicalCookieNameIs, "") {}

}  // namespace net

#endif  // NET_COOKIES_CANONICAL_COOKIE_TEST_HELPERS_H_