This patch combine three patch which is related to "--gcov" flag.
[platform/framework/web/chromium-efl.git] / gin / v8_shared_memory_dump_provider_unittest.cc
1 // Copyright 2019 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 "gin/v8_shared_memory_dump_provider.h"
6
7 #include <memory>
8
9 #include "base/containers/contains.h"
10 #include "base/trace_event/process_memory_dump.h"
11 #include "base/trace_event/trace_event.h"
12 #include "gin/test/v8_test.h"
13
14 namespace gin {
15
16 typedef V8Test V8SharedMemoryDumpProviderTest;
17
18 // Checks if the dump provider runs without crashing and dumps root objects.
19 TEST_F(V8SharedMemoryDumpProviderTest, DumpStatistics) {
20   V8SharedMemoryDumpProvider provider;
21
22   base::trace_event::MemoryDumpArgs dump_args = {
23       base::trace_event::MemoryDumpLevelOfDetail::kDetailed};
24   std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
25       new base::trace_event::ProcessMemoryDump(dump_args));
26   provider.OnMemoryDump(dump_args, process_memory_dump.get());
27   const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
28       allocator_dumps = process_memory_dump->allocator_dumps();
29
30   bool did_dump_shared_memory_stats = false;
31   bool did_dump_read_only_space = false;
32   for (const auto& name_dump : allocator_dumps) {
33     const std::string& name = name_dump.first;
34     if (base::Contains(name, "v8/shared")) {
35       did_dump_shared_memory_stats = true;
36     }
37     if (base::Contains(name, "v8/shared/read_only_space")) {
38       did_dump_read_only_space = true;
39     }
40   }
41
42   ASSERT_TRUE(did_dump_shared_memory_stats);
43   ASSERT_TRUE(did_dump_read_only_space);
44 }
45
46 }  // namespace gin