Commit b3f0cfdc authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Revert "[Autofill Assistant] Added missing unit tests for new service deps."

This reverts commit c66038fc.

Reason for revert: Closed the tree (see ci.chromium.org/p/chromium/builders/ci/android-marshmallow-arm64-rel/23070)

Original change's description:
> [Autofill Assistant] Added missing unit tests for new service deps.
>
> Bug: b/158998456
> Change-Id: Ib580385e201a1b68967dcace71af8cd8f2ed58e2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450309
> Commit-Queue: Clemens Arbesser <arbesser@google.com>
> Reviewed-by: Sandro Maggi <sandromaggi@google.com>
> Cr-Commit-Position: refs/heads/master@{#814184}

TBR=arbesser@google.com,sandromaggi@google.com

Change-Id: I782c69bbf71fa3dcf4bacde008970d8ed974a4a2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/158998456
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2451216Reviewed-by: default avatarDominique Fauteux-Chapleau <domfc@chromium.org>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814192}
parent b4ba4bc8
......@@ -302,10 +302,8 @@ source_set("unit_tests") {
"script_precondition_unittest.cc",
"script_tracker_unittest.cc",
"selector_unittest.cc",
"service/api_key_fetcher_unittest.cc",
"service/lite_service_unittest.cc",
"service/lite_service_util_unittest.cc",
"service/server_url_fetcher_unittest.cc",
"string_conversions_util_unittest.cc",
"test_util.cc",
"test_util.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/autofill_assistant/browser/service/api_key_fetcher.h"
#include "base/command_line.h"
#include "components/autofill_assistant/browser/switches.h"
#include "components/version_info/version_info.h"
#include "google_apis/google_api_keys.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace autofill_assistant {
namespace {
using ::testing::Eq;
TEST(ApiKeyFetcherTest, GetAPIKeyCommandLineOverride) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kAutofillAssistantServerKey, "fake_key");
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::STABLE),
Eq("fake_key"));
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::UNKNOWN),
Eq("fake_key"));
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::CANARY),
Eq("fake_key"));
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::DEV),
Eq("fake_key"));
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::BETA),
Eq("fake_key"));
}
TEST(ApiKeyFetcherTest, GetAPIKeyReturnsStableAndNonstableKeys) {
base::CommandLine::ForCurrentProcess()->RemoveSwitch(
switches::kAutofillAssistantServerKey);
// Only run tests on Google Chrome builds. This intentionally does not gate
// the test with a precompiler definition, because a change to
// |IsGoogleChromeAPIKeyUsed| would go unnoticed by us.
if (!google_apis::IsGoogleChromeAPIKeyUsed()) {
return;
}
std::string api_key_stable = google_apis::GetAPIKey();
std::string api_key_nonstable = google_apis::GetNonStableAPIKey();
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::STABLE),
Eq(api_key_stable));
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::UNKNOWN),
Eq(api_key_nonstable));
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::CANARY),
Eq(api_key_nonstable));
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::DEV),
Eq(api_key_nonstable));
EXPECT_THAT(ApiKeyFetcher().GetAPIKey(version_info::Channel::BETA),
Eq(api_key_nonstable));
}
} // namespace
} // namespace autofill_assistant
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/autofill_assistant/browser/service/server_url_fetcher.h"
#include "base/command_line.h"
#include "components/autofill_assistant/browser/switches.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace autofill_assistant {
namespace {
using ::testing::Eq;
TEST(ServerUrlFetcherTest, GetDefaultServerUrl) {
base::CommandLine::ForCurrentProcess()->RemoveSwitch(
switches::kAutofillAssistantUrl);
EXPECT_THAT(ServerUrlFetcher::GetDefaultServerUrl(),
Eq(GURL("https://automate-pa.googleapis.com")));
}
TEST(ServerUrlFetcherTest, GetDefaultServerUrlCommandLineOverride) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kAutofillAssistantUrl, "https://www.example.com");
EXPECT_THAT(ServerUrlFetcher::GetDefaultServerUrl(),
Eq(GURL("https://www.example.com")));
}
TEST(ServerUrlFetcherTest, GetScriptsEndpoint) {
EXPECT_THAT(
ServerUrlFetcher(GURL("https://www.example.com")).GetScriptsEndpoint(),
Eq(GURL("https://www.example.com/v1/supportsSite2")));
}
TEST(ServerUrlFetcherTest, GetActionsEndpoint) {
EXPECT_THAT(
ServerUrlFetcher(GURL("https://www.example.com")).GetActionsEndpoint(),
Eq(GURL("https://www.example.com/v1/actions2")));
}
} // namespace
} // namespace autofill_assistant
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment