fixup! [M120 Migration] Notify media device state to webbrowser
[platform/framework/web/chromium-efl.git] / base / check_is_test.cc
1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/check_is_test.h"
6
7 #include "base/check.h"
8 #include "base/logging.h"
9
10 namespace {
11 bool g_this_is_a_test = false;
12 }
13
14 namespace base::internal {
15 void check_is_test_impl() {
16   CHECK(g_this_is_a_test);
17 }
18 }  // namespace base::internal
19
20 namespace base::test {
21 // base/test/allow_check_is_test_for_testing.h declares
22 // `AllowCheckIsTestForTesting`, but is only allowed to be included in test
23 // code. We therefore have to also mark the symbol as exported here.
24 BASE_EXPORT void AllowCheckIsTestForTesting() {
25   // This CHECK ensures that `AllowCheckIsTestForTesting` is called
26   // just once. Since it is called in `base::TestSuite`, this should effectivly
27   // prevent calls to `AllowCheckIsTestForTesting` in production code
28   // (assuming that code has unit test coverage).
29   //
30   // This is just in case someone ignores the fact that this function in the
31   // `base::test` namespace and ends on "ForTesting".
32   CHECK(!g_this_is_a_test)
33       << "AllowCheckIsTestForTesting must not be called more than once";
34
35   g_this_is_a_test = true;
36 }
37
38 }  // namespace base::test