[M85 Dev][EFL] Fix crashes at webview launch
[platform/framework/web/chromium-efl.git] / base / location_unittest.cc
1 // Copyright 2019 The Chromium Authors. All rights reserved.
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/location.h"
6
7 #include "base/compiler_specific.h"
8 #include "base/debug/debugging_buildflags.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace base {
13
14 namespace {
15
16 // This is a typical use: taking Location::Current as a default parameter.
17 // So even though this looks contrived, it confirms that such usage works as
18 // expected.
19 Location WhereAmI(const Location& location = Location::Current()) {
20   return location;
21 }
22
23 }  // namespace
24
25 TEST(LocationTest, CurrentYieldsCorrectValue) {
26   int previous_line = __LINE__;
27   Location here = WhereAmI();
28   EXPECT_NE(here.program_counter(), WhereAmI().program_counter());
29 #if SUPPORTS_LOCATION_BUILTINS
30   EXPECT_THAT(here.file_name(), ::testing::EndsWith("location_unittest.cc"));
31 #if BUILDFLAG(ENABLE_LOCATION_SOURCE)
32   EXPECT_EQ(here.line_number(), previous_line + 1);
33   EXPECT_STREQ("TestBody", here.function_name());
34 #endif
35 #elif defined(OFFICIAL_BUILD)
36 #error Location builtins must be supported in official builds.
37 #elif BUILDFLAG(FROM_HERE_USES_LOCATION_BUILTINS)
38 #error FROM_HERE requires location builtins to be supported.
39 #endif
40   ALLOW_UNUSED_LOCAL(previous_line);
41 }
42
43 }  // namespace base