Rename AllowCheckIsTestToBeCalled to [...]ForTesting

This is yet another hint to prevent the function from being used in
production code. This allows us to drop the warning message.

Bug: 1326801
Change-Id: I76d786dd0225493ffa04f65ec1f36ff89192a65c
Tests: Non-functional change (rename).
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3970673
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Daniel Cheng <[email protected]>
Owners-Override: Daniel Cheng <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1062542}
diff --git a/base/check_is_test.cc b/base/check_is_test.cc
index 8f4132d..0c5a625 100644
--- a/base/check_is_test.cc
+++ b/base/check_is_test.cc
@@ -18,21 +18,19 @@
 }  // namespace base::internal
 
 namespace base::test {
-// base/test/allow_check_is_test_to_be_called.h declares
-// `AllowCheckIsTestToBeCalled`, but is only allowed to be included in test
-// code.
-// We therefore have to also mark the symbol as exported here.
-BASE_EXPORT void AllowCheckIsTestToBeCalled() {
-  LOG(WARNING) << "Allowing special test code paths";
-  // This CHECK ensures that `AllowCheckIsTestToBeCalled` is called just once.
-  // Since it is called in `base::TestSuite`, this should effectivly prevent
-  // calls to AllowCheckIsTestToBeCalled in production code (assuming that code
-  // has unit test coverage).
+// base/test/allow_check_is_test_for_testing.h declares
+// `AllowCheckIsTestForTesting`, but is only allowed to be included in test
+// code. We therefore have to also mark the symbol as exported here.
+BASE_EXPORT void AllowCheckIsTestForTesting() {
+  // This CHECK ensures that `AllowCheckIsTestForTesting` is called
+  // just once. Since it is called in `base::TestSuite`, this should effectivly
+  // prevent calls to `AllowCheckIsTestForTesting` in production code
+  // (assuming that code has unit test coverage).
   //
   // This is just in case someone ignores the fact that this function in the
   // `base::test` namespace and ends on "ForTesting".
   CHECK(!g_this_is_a_test)
-      << "AllowCheckIsTestToBeCalled must not be called more than once";
+      << "AllowCheckIsTestForTesting must not be called more than once";
 
   g_this_is_a_test = true;
 }
diff --git a/base/check_is_test_unittest.cc b/base/check_is_test_unittest.cc
index 1c47e62..3f7fa36c 100644
--- a/base/check_is_test_unittest.cc
+++ b/base/check_is_test_unittest.cc
@@ -6,7 +6,7 @@
 
 #include "testing/gtest/include/gtest/gtest.h"
 
-// Note: `base::AllowCheckIsTestToBeCalled` is being called in
+// Note: `base::AllowCheckIsTestForTesting` is being called in
 // `base/test/launcher/unit_test_launcher.cc` before this test is run.
 //
 // Thus, `CHECK_IS_TEST()` will succeed.
diff --git a/base/test/BUILD.gn b/base/test/BUILD.gn
index 4b64543df..e5f88a2 100644
--- a/base/test/BUILD.gn
+++ b/base/test/BUILD.gn
@@ -43,7 +43,7 @@
     "../task/sequence_manager/test/test_task_time_observer.h",
     "../timer/mock_timer.cc",
     "../timer/mock_timer.h",
-    "allow_check_is_test_to_be_called.h",
+    "allow_check_is_test_for_testing.h",
     "bind.cc",
     "bind.h",
     "copy_only_int.cc",
diff --git a/base/test/allow_check_is_test_for_testing.h b/base/test/allow_check_is_test_for_testing.h
new file mode 100644
index 0000000..1ce6cc6e
--- /dev/null
+++ b/base/test/allow_check_is_test_for_testing.h
@@ -0,0 +1,20 @@
+// Copyright 2022 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_TEST_ALLOW_CHECK_IS_TEST_FOR_TESTING_H_
+#define BASE_TEST_ALLOW_CHECK_IS_TEST_FOR_TESTING_H_
+
+namespace base::test {
+
+// This is to be called exactly once when starting unit or browser tests to
+// allow test-only code paths that contain `CHECK_IS_TEST()`. It must be called
+// before we have other threads to avoid races with calls to `CHECK_IS_TEST()`.
+//
+// Note: This function must not be called in production code, but only in
+// tests.
+void AllowCheckIsTestForTesting();
+
+}  // namespace base::test
+
+#endif  // BASE_TEST_ALLOW_CHECK_IS_TEST_FOR_TESTING_H_
diff --git a/base/test/allow_check_is_test_to_be_called.h b/base/test/allow_check_is_test_to_be_called.h
deleted file mode 100644
index 03a6db1..0000000
--- a/base/test/allow_check_is_test_to_be_called.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_TEST_ALLOW_CHECK_IS_TEST_TO_BE_CALLED_H_
-#define BASE_TEST_ALLOW_CHECK_IS_TEST_TO_BE_CALLED_H_
-
-namespace base::test {
-
-// This is to be called exactly once when starting unit or browser tests to
-// allow test-only code paths that contain `CHECK_IS_TEST()`.
-//
-// Note: This function must not be called in production code, but only in
-// tests.
-void AllowCheckIsTestToBeCalled();
-
-}  // namespace base::test
-
-#endif  // BASE_TEST_ALLOW_CHECK_IS_TEST_TO_BE_CALLED_H_
diff --git a/base/test/launcher/unit_test_launcher.cc b/base/test/launcher/unit_test_launcher.cc
index 22895c3..4d373f14 100644
--- a/base/test/launcher/unit_test_launcher.cc
+++ b/base/test/launcher/unit_test_launcher.cc
@@ -26,7 +26,7 @@
 #include "base/system/sys_info.h"
 #include "base/task/single_thread_task_executor.h"
 #include "base/task/single_thread_task_runner.h"
-#include "base/test/allow_check_is_test_to_be_called.h"
+#include "base/test/allow_check_is_test_for_testing.h"
 #include "base/test/launcher/test_launcher.h"
 #include "base/test/test_switches.h"
 #include "base/test/test_timeouts.h"
@@ -149,7 +149,7 @@
                             bool use_job_objects,
                             RepeatingClosure timeout_callback,
                             OnceClosure gtest_init) {
-  base::test::AllowCheckIsTestToBeCalled();
+  base::test::AllowCheckIsTestForTesting();
 
 #if BUILDFLAG(IS_ANDROID)
   // We can't easily fork on Android, just run the test suite directly.
diff --git a/base/test/launcher/unit_test_launcher_ios.cc b/base/test/launcher/unit_test_launcher_ios.cc
index bceac7a..c756f8c 100644
--- a/base/test/launcher/unit_test_launcher_ios.cc
+++ b/base/test/launcher/unit_test_launcher_ios.cc
@@ -9,7 +9,7 @@
 #include "base/files/file_util.h"
 #include "base/logging.h"
 #include "base/mac/foundation_util.h"
-#include "base/test/allow_check_is_test_to_be_called.h"
+#include "base/test/allow_check_is_test_for_testing.h"
 #include "base/test/gtest_util.h"
 #include "base/test/test_switches.h"
 
@@ -32,7 +32,7 @@
                     char** argv,
                     RunTestSuiteCallback run_test_suite,
                     size_t retry_limit) {
-  base::test::AllowCheckIsTestToBeCalled();
+  base::test::AllowCheckIsTestForTesting();
 
   return LaunchUnitTestsSerially(argc, argv, std::move(run_test_suite));
 }