#include "chrome/test/chromedriver/capabilities.h"
#include <utility>
#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/strings/pattern.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/test/chromedriver/chrome/client_hints.h"
#include "chrome/test/chromedriver/chrome/log.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/logging.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
Eq;
Pointee;
namespace {
template <int Code>
testing::AssertionResult StatusCodeIs(const Status& status) { … }
testing::AssertionResult StatusOk(const Status& status) { … }
void CheckDefaults(const ClientHints& client_hints) { … }
const char kUserAgentChromeOnWindows[] = …;
const char kUserAgentChromeOnMacOS[] = …;
const char kUserAgentChromeOnLinux[] = …;
const char kUserAgentChromeOnChromeOS[] = …;
const char kUserAgentChromeOnFuchsia[] = …;
const char kUserAgentMobileChromeOnAndroid[] = …;
const char kUserAgentNonMobileChromeOnAndroid[] = …;
const char kUserAgentMobileChromeOnIOS[] = …;
const char kUserAgentNonMobileChromeOnIOS[] = …;
const std::vector<std::string> kNonMobileUserAgents = …;
}
TEST(Switches, Empty) { … }
TEST(Switches, NoValue) { … }
TEST(Switches, Value) { … }
TEST(Switches, FromOther) { … }
TEST(Switches, Remove) { … }
TEST(Switches, Quoting) { … }
TEST(Switches, Multiple) { … }
TEST(Switches, Unparsed) { … }
TEST(ParseCapabilities, UnknownCapabilityLegacy) { … }
TEST(ParseCapabilities, UnknownCapabilityW3c) { … }
TEST(ParseCapabilities, WithAndroidPackage) { … }
TEST(ParseCapabilities, EmptyAndroidPackage) { … }
TEST(ParseCapabilities, IllegalAndroidPackage) { … }
TEST(ParseCapabilities, LogPath) { … }
TEST(ParseCapabilities, Args) { … }
TEST(ParseCapabilities, Prefs) { … }
TEST(ParseCapabilities, LocalState) { … }
TEST(ParseCapabilities, Extensions) { … }
TEST(ParseCapabilities, UnrecognizedProxyType) { … }
TEST(ParseCapabilities, IllegalProxyType) { … }
TEST(ParseCapabilities, DirectProxy) { … }
TEST(ParseCapabilities, SystemProxy) { … }
TEST(ParseCapabilities, PacProxy) { … }
TEST(ParseCapabilities, MissingProxyAutoconfigUrl) { … }
TEST(ParseCapabilities, AutodetectProxy) { … }
TEST(ParseCapabilities, ManualProxy) { … }
TEST(ParseCapabilities, IgnoreNullValueForManualProxy) { … }
TEST(ParseCapabilities, MissingSocksVersion) { … }
TEST(ParseCapabilities, BadSocksVersion) { … }
TEST(ParseCapabilities, AcceptInsecureCertsDisabledByDefault) { … }
TEST(ParseCapabilities, EnableAcceptInsecureCerts) { … }
TEST(ParseCapabilities, LoggingPrefsOk) { … }
TEST(ParseCapabilities, LoggingPrefsNotDict) { … }
TEST(ParseCapabilities, PerfLoggingPrefsInspectorDomainStatus) { … }
TEST(ParseCapabilities, PerfLoggingPrefsTracing) { … }
TEST(ParseCapabilities, PerfLoggingPrefsInvalidInterval) { … }
TEST(ParseCapabilities, PerfLoggingPrefsNotDict) { … }
TEST(ParseCapabilities, PerfLoggingPrefsNoPerfLogLevel) { … }
TEST(ParseCapabilities, PerfLoggingPrefsPerfLogOff) { … }
TEST(ParseCapabilities, ExcludeSwitches) { … }
TEST(ParseCapabilities, UseRemoteBrowserHostName) { … }
TEST(ParseCapabilities, UseRemoteBrowserIpv4) { … }
TEST(ParseCapabilities, UseRemoteBrowserIpv6) { … }
TEST(ParseCapabilities, MobileEmulationUserAgent) { … }
TEST(ParseCapabilities, MobileEmulationDeviceMetrics) { … }
TEST(ParseCapabilities, MobileEmulationDeviceName) { … }
TEST(ParseCapabilities, MobileEmulationNotDict) { … }
TEST(ParseCapabilities, MobileEmulationDeviceMetricsNotDict) { … }
TEST(ParseCapabilities, MobileEmulationDeviceMetricsNotNumbers) { … }
TEST(ParseCapabilities, MobileEmulationBadDict) { … }
TEST(ParseCapabilities, VirtualAuthenticatorsBool) { … }
TEST(ParseCapabilities, VirtualAuthenticatorsNotBool) { … }
TEST(ParseCapabilities, VirtualAuthenticatorsLargeBlobBool) { … }
TEST(ParseCapabilities, VirtualAuthenticatorsLargeBlobNotBool) { … }
TEST(ParseCapabilities, FedcmAccountsBool) { … }
TEST(ParseCapabilities, FedcmAccountsNotBool) { … }
namespace {
base::Value::Dict CreateCapabilitiesDict(const std::string& mobile_emulation) { … }
}
TEST(ParseClientHints, MinimalistMobileAndroid) { … }
TEST(ParseClientHints, MinimalistTabletAndroid) { … }
class ParseClientHintsPerPlatform
: public testing::TestWithParam<std::pair<std::string, std::string>> { … };
TEST_P(ParseClientHintsPerPlatform, MinimalistDesktop) { … }
TEST_P(ParseClientHintsPerPlatform, MobileDeviceMetrics) { … }
TEST_P(ParseClientHintsPerPlatform, TabletDeviceMetrics) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST(ParseClientHints, MinimalistCustomMobile) { … }
TEST(ParseClientHints, MinimalistCustomTablet) { … }
class InferClientHintsOnAndroid
: public testing::TestWithParam<std::pair<std::string, bool>> { … };
TEST_P(InferClientHintsOnAndroid, NoDeviceMetrics) { … }
TEST_P(InferClientHintsOnAndroid, MobileDeviceMetrics) { … }
TEST_P(InferClientHintsOnAndroid, TabletDeviceMetrics) { … }
INSTANTIATE_TEST_SUITE_P(…);
class InferClientHintsPerPlatform
: public testing::TestWithParam<std::pair<std::string, std::string>> { … };
TEST_P(InferClientHintsPerPlatform, NoDeviceMetrics) { … }
TEST_P(InferClientHintsPerPlatform, MobileDeviceMetrics) { … }
TEST_P(InferClientHintsPerPlatform, TabletDeviceMetrics) { … }
INSTANTIATE_TEST_SUITE_P(…);
class InferClientHintsOnCustomPlatform
: public testing::TestWithParam<std::string> { … };
TEST_P(InferClientHintsOnCustomPlatform, NoDeviceMetrics) { … }
TEST_P(InferClientHintsOnCustomPlatform, MobileDeviceMetrics) { … }
TEST_P(InferClientHintsOnCustomPlatform, TabletDeviceMetrics) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST(ParseClientHints, NoUserAgentNoClientHints) { … }
TEST(ParseClientHints, EmptyClientHints) { … }
TEST(ParseClientHints, RequireUserAgentForCustomPlatform) { … }
TEST(ParseClientHints, WrongClientHintsType) { … }
TEST(ParseClientHints, WrongClientHintsProperties) { … }
TEST(ParseClientHints, CustomClientHints) { … }
TEST(ParseClientHints, MalformedBrands) { … }
TEST(ParseClientHints, MalformedFullVersionList) { … }