0

Inline test-only CoreAccountId constructors

The approach replaced in this patch doesn't work well with making
//google_apis a component, which is the current plan.

These constructors can be ifdef-ed for unit tests only, which also
requires that they are inlined in the header file.

Note that, as per pre-existing TODO, these constructors will eventually
be deleted.

Change-Id: I47a128d9887eb19875b348919a04a186cfd38402
Bug: 1417961
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272397
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1107684}
This commit is contained in:
Mikel Astiz
2023-02-21 12:30:41 +00:00
committed by Chromium LUCI CQ
parent 89e1eb8d0f
commit 7543d90eb4
3 changed files with 10 additions and 19 deletions

@ -213,7 +213,6 @@ proto_library("oauth2_mint_token_consent_result_proto") {
static_library("test_support") {
testonly = true
sources = [
"gaia/core_account_id_for_testing.cc",
"gaia/fake_gaia.cc",
"gaia/fake_gaia.h",
"gaia/fake_oauth2_access_token_manager.cc",

@ -77,16 +77,19 @@ struct CoreAccountId {
// --------------------------------------------------------------------------
// -------------------- ONLY FOR TESTING ------------------------------------
// The following constructors are only used for testing. Their implementation
// is defined in core_account_id_for_testing.cc and is not linked in the
// production code. The reason for this is that they are currently being
// removed, but they are extensively used by the testing code.
#if defined(UNIT_TEST)
// The following constructors are only used for testing. The reason for this
// is that they are currently being removed, but they are extensively used by
// the testing code.
//
// TODO(crbug.com/1028578): Update the tests to use one of FromEmail(),
// FromGaia() or FromString() methods above.
explicit CoreAccountId(const char* id);
explicit CoreAccountId(std::string&& id);
explicit CoreAccountId(const std::string& id);
explicit CoreAccountId(const char* id) : id_(id) {}
explicit CoreAccountId(std::string&& id) : id_(std::move(id)) {}
explicit CoreAccountId(const std::string& id) : id_(id) {}
#endif // defined(UNIT_TEST)
// --------------------------------------------------------------------------
private:

@ -1,11 +0,0 @@
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "google_apis/gaia/core_account_id.h"
CoreAccountId::CoreAccountId(const char* id) : id_(id) {}
CoreAccountId::CoreAccountId(std::string&& id) : id_(std::move(id)) {}
CoreAccountId::CoreAccountId(const std::string& id) : id_(id) {}