OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/trace_event/memory_allocator_dump.h" | 5 #include "base/trace_event/memory_allocator_dump.h" |
6 #include "base/trace_event/process_memory_dump.h" | 6 #include "base/trace_event/process_memory_dump.h" |
7 #include "base/trace_event/trace_event_argument.h" | 7 #include "base/trace_event/trace_event_argument.h" |
8 #include "components/tracing/common/graphics_memory_dump_provider_android.h" | 8 #include "components/tracing/common/graphics_memory_dump_provider_android.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace tracing { | 11 namespace tracing { |
12 | 12 |
13 TEST(GraphicsMemoryDumpProviderTest, ParseResponse) { | 13 TEST(GraphicsMemoryDumpProviderTest, ParseResponse) { |
14 const char* kDumpBaseName = GraphicsMemoryDumpProvider::kDumpBaseName; | 14 const char* kDumpBaseName = GraphicsMemoryDumpProvider::kDumpBaseName; |
15 | 15 |
16 base::trace_event::ProcessMemoryDump pmd(nullptr); | 16 base::trace_event::ProcessMemoryDump pmd( |
| 17 nullptr, {base::trace_event::MemoryDumpLevelOfDetail::DETAILED}); |
17 auto instance = GraphicsMemoryDumpProvider::GetInstance(); | 18 auto instance = GraphicsMemoryDumpProvider::GetInstance(); |
18 char buf[] = "graphics_total 12\ngraphics_pss 34\ngl_total 56\ngl_pss 78"; | 19 char buf[] = "graphics_total 12\ngraphics_pss 34\ngl_total 56\ngl_pss 78"; |
19 instance->ParseResponseAndAddToDump(buf, strlen(buf), &pmd); | 20 instance->ParseResponseAndAddToDump(buf, strlen(buf), &pmd); |
20 | 21 |
21 // Check the "graphics" row. | 22 // Check the "graphics" row. |
22 auto mad = pmd.GetAllocatorDump(kDumpBaseName + std::string("graphics")); | 23 auto mad = pmd.GetAllocatorDump(kDumpBaseName + std::string("graphics")); |
23 ASSERT_TRUE(mad); | 24 ASSERT_TRUE(mad); |
24 std::string json; | 25 std::string json; |
25 mad->attributes_for_testing()->AppendAsTraceFormat(&json); | 26 mad->attributes_for_testing()->AppendAsTraceFormat(&json); |
26 ASSERT_EQ( | 27 ASSERT_EQ( |
(...skipping 16 matching lines...) Expand all Loading... |
43 json); | 44 json); |
44 | 45 |
45 // Test for truncated input. | 46 // Test for truncated input. |
46 pmd.Clear(); | 47 pmd.Clear(); |
47 instance->ParseResponseAndAddToDump(buf, strlen(buf) - 14, &pmd); | 48 instance->ParseResponseAndAddToDump(buf, strlen(buf) - 14, &pmd); |
48 ASSERT_TRUE(pmd.GetAllocatorDump(kDumpBaseName + std::string("graphics"))); | 49 ASSERT_TRUE(pmd.GetAllocatorDump(kDumpBaseName + std::string("graphics"))); |
49 ASSERT_FALSE(pmd.GetAllocatorDump(kDumpBaseName + std::string("gl"))); | 50 ASSERT_FALSE(pmd.GetAllocatorDump(kDumpBaseName + std::string("gl"))); |
50 } | 51 } |
51 | 52 |
52 } // namespace tracing | 53 } // namespace tracing |
OLD | NEW |