Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Side by Side Diff: components/metrics/leak_detector/protobuf_to_mojo_converter_unittest.cc

Issue 2417403002: Revert of Leak reports collect information about the last uptrend (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/metrics/leak_detector/protobuf_to_mojo_converter.h" 5 #include "components/metrics/leak_detector/protobuf_to_mojo_converter.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace metrics { 9 namespace metrics {
10 namespace leak_detector { 10 namespace leak_detector {
(...skipping 27 matching lines...) Expand all
38 EXPECT_EQ(8U, new_params.size_suspicion_threshold()); 38 EXPECT_EQ(8U, new_params.size_suspicion_threshold());
39 EXPECT_EQ(11U, new_params.call_stack_suspicion_threshold()); 39 EXPECT_EQ(11U, new_params.call_stack_suspicion_threshold());
40 } 40 }
41 41
42 TEST(protobuf_to_mojo_converterTest, ConvertReport) { 42 TEST(protobuf_to_mojo_converterTest, ConvertReport) {
43 MemoryLeakReportProto report; 43 MemoryLeakReportProto report;
44 report.add_call_stack(0xdeadbeef); 44 report.add_call_stack(0xdeadbeef);
45 report.add_call_stack(0xc001d00d); 45 report.add_call_stack(0xc001d00d);
46 report.add_call_stack(0x900df00d); 46 report.add_call_stack(0x900df00d);
47 report.set_size_bytes(24); 47 report.set_size_bytes(24);
48 report.set_num_rising_intervals(5);
49 report.set_num_allocs_increase(42);
50 48
51 auto entry1 = report.add_alloc_breakdown_history(); 49 auto entry1 = report.add_alloc_breakdown_history();
52 entry1->add_counts_by_size(1); 50 entry1->add_counts_by_size(1);
53 entry1->add_counts_by_size(2); 51 entry1->add_counts_by_size(2);
54 entry1->add_counts_by_size(3); 52 entry1->add_counts_by_size(3);
55 entry1->set_count_for_call_stack(4); 53 entry1->set_count_for_call_stack(4);
56 54
57 auto entry2 = report.add_alloc_breakdown_history(); 55 auto entry2 = report.add_alloc_breakdown_history();
58 entry2->add_counts_by_size(11); 56 entry2->add_counts_by_size(11);
59 entry2->add_counts_by_size(12); 57 entry2->add_counts_by_size(12);
(...skipping 12 matching lines...) Expand all
72 // Convert to equivalent Mojo struct. 70 // Convert to equivalent Mojo struct.
73 mojo::StructPtr<mojom::MemoryLeakReport> mojo_report = 71 mojo::StructPtr<mojom::MemoryLeakReport> mojo_report =
74 mojom::MemoryLeakReport::New(); 72 mojom::MemoryLeakReport::New();
75 protobuf_to_mojo_converter::ReportToMojo(report, mojo_report.get()); 73 protobuf_to_mojo_converter::ReportToMojo(report, mojo_report.get());
76 74
77 ASSERT_EQ(3U, mojo_report->call_stack.size()); 75 ASSERT_EQ(3U, mojo_report->call_stack.size());
78 EXPECT_EQ(0xdeadbeef, mojo_report->call_stack[0]); 76 EXPECT_EQ(0xdeadbeef, mojo_report->call_stack[0]);
79 EXPECT_EQ(0xc001d00d, mojo_report->call_stack[1]); 77 EXPECT_EQ(0xc001d00d, mojo_report->call_stack[1]);
80 EXPECT_EQ(0x900df00d, mojo_report->call_stack[2]); 78 EXPECT_EQ(0x900df00d, mojo_report->call_stack[2]);
81 EXPECT_EQ(24U, mojo_report->size_bytes); 79 EXPECT_EQ(24U, mojo_report->size_bytes);
82 EXPECT_EQ(5U, mojo_report->num_rising_intervals);
83 EXPECT_EQ(42U, mojo_report->num_allocs_increase);
84 80
85 ASSERT_EQ(3U, mojo_report->alloc_breakdown_history.size()); 81 ASSERT_EQ(3U, mojo_report->alloc_breakdown_history.size());
86 82
87 ASSERT_EQ(3U, mojo_report->alloc_breakdown_history[0]->counts_by_size.size()); 83 ASSERT_EQ(3U, mojo_report->alloc_breakdown_history[0]->counts_by_size.size());
88 EXPECT_EQ(1U, mojo_report->alloc_breakdown_history[0]->counts_by_size[0]); 84 EXPECT_EQ(1U, mojo_report->alloc_breakdown_history[0]->counts_by_size[0]);
89 EXPECT_EQ(2U, mojo_report->alloc_breakdown_history[0]->counts_by_size[1]); 85 EXPECT_EQ(2U, mojo_report->alloc_breakdown_history[0]->counts_by_size[1]);
90 EXPECT_EQ(3U, mojo_report->alloc_breakdown_history[0]->counts_by_size[2]); 86 EXPECT_EQ(3U, mojo_report->alloc_breakdown_history[0]->counts_by_size[2]);
91 EXPECT_EQ(4U, mojo_report->alloc_breakdown_history[0]->count_for_call_stack); 87 EXPECT_EQ(4U, mojo_report->alloc_breakdown_history[0]->count_for_call_stack);
92 88
93 ASSERT_EQ(4U, mojo_report->alloc_breakdown_history[1]->counts_by_size.size()); 89 ASSERT_EQ(4U, mojo_report->alloc_breakdown_history[1]->counts_by_size.size());
(...skipping 13 matching lines...) Expand all
107 103
108 // Convert Mojo struct back to protobuf. 104 // Convert Mojo struct back to protobuf.
109 MemoryLeakReportProto new_report; 105 MemoryLeakReportProto new_report;
110 protobuf_to_mojo_converter::MojoToReport(*mojo_report, &new_report); 106 protobuf_to_mojo_converter::MojoToReport(*mojo_report, &new_report);
111 107
112 ASSERT_EQ(3, new_report.call_stack().size()); 108 ASSERT_EQ(3, new_report.call_stack().size());
113 EXPECT_EQ(0xdeadbeef, new_report.call_stack(0)); 109 EXPECT_EQ(0xdeadbeef, new_report.call_stack(0));
114 EXPECT_EQ(0xc001d00d, new_report.call_stack(1)); 110 EXPECT_EQ(0xc001d00d, new_report.call_stack(1));
115 EXPECT_EQ(0x900df00d, new_report.call_stack(2)); 111 EXPECT_EQ(0x900df00d, new_report.call_stack(2));
116 EXPECT_EQ(24U, new_report.size_bytes()); 112 EXPECT_EQ(24U, new_report.size_bytes());
117 EXPECT_EQ(5U, new_report.num_rising_intervals());
118 EXPECT_EQ(42U, new_report.num_allocs_increase());
119 113
120 ASSERT_EQ(3, new_report.alloc_breakdown_history().size()); 114 ASSERT_EQ(3, new_report.alloc_breakdown_history().size());
121 115
122 ASSERT_EQ(3, new_report.alloc_breakdown_history(0).counts_by_size().size()); 116 ASSERT_EQ(3, new_report.alloc_breakdown_history(0).counts_by_size().size());
123 EXPECT_EQ(1U, new_report.alloc_breakdown_history(0).counts_by_size(0)); 117 EXPECT_EQ(1U, new_report.alloc_breakdown_history(0).counts_by_size(0));
124 EXPECT_EQ(2U, new_report.alloc_breakdown_history(0).counts_by_size(1)); 118 EXPECT_EQ(2U, new_report.alloc_breakdown_history(0).counts_by_size(1));
125 EXPECT_EQ(3U, new_report.alloc_breakdown_history(0).counts_by_size(2)); 119 EXPECT_EQ(3U, new_report.alloc_breakdown_history(0).counts_by_size(2));
126 EXPECT_EQ(4U, new_report.alloc_breakdown_history(0).count_for_call_stack()); 120 EXPECT_EQ(4U, new_report.alloc_breakdown_history(0).count_for_call_stack());
127 121
128 ASSERT_EQ(4, new_report.alloc_breakdown_history(1).counts_by_size().size()); 122 ASSERT_EQ(4, new_report.alloc_breakdown_history(1).counts_by_size().size());
129 EXPECT_EQ(11U, new_report.alloc_breakdown_history(1).counts_by_size(0)); 123 EXPECT_EQ(11U, new_report.alloc_breakdown_history(1).counts_by_size(0));
130 EXPECT_EQ(12U, new_report.alloc_breakdown_history(1).counts_by_size(1)); 124 EXPECT_EQ(12U, new_report.alloc_breakdown_history(1).counts_by_size(1));
131 EXPECT_EQ(13U, new_report.alloc_breakdown_history(1).counts_by_size(2)); 125 EXPECT_EQ(13U, new_report.alloc_breakdown_history(1).counts_by_size(2));
132 EXPECT_EQ(14U, new_report.alloc_breakdown_history(1).counts_by_size(3)); 126 EXPECT_EQ(14U, new_report.alloc_breakdown_history(1).counts_by_size(3));
133 EXPECT_EQ(15U, new_report.alloc_breakdown_history(1).count_for_call_stack()); 127 EXPECT_EQ(15U, new_report.alloc_breakdown_history(1).count_for_call_stack());
134 128
135 ASSERT_EQ(5, new_report.alloc_breakdown_history(2).counts_by_size().size()); 129 ASSERT_EQ(5, new_report.alloc_breakdown_history(2).counts_by_size().size());
136 EXPECT_EQ(21U, new_report.alloc_breakdown_history(2).counts_by_size(0)); 130 EXPECT_EQ(21U, new_report.alloc_breakdown_history(2).counts_by_size(0));
137 EXPECT_EQ(22U, new_report.alloc_breakdown_history(2).counts_by_size(1)); 131 EXPECT_EQ(22U, new_report.alloc_breakdown_history(2).counts_by_size(1));
138 EXPECT_EQ(23U, new_report.alloc_breakdown_history(2).counts_by_size(2)); 132 EXPECT_EQ(23U, new_report.alloc_breakdown_history(2).counts_by_size(2));
139 EXPECT_EQ(24U, new_report.alloc_breakdown_history(2).counts_by_size(3)); 133 EXPECT_EQ(24U, new_report.alloc_breakdown_history(2).counts_by_size(3));
140 EXPECT_EQ(25U, new_report.alloc_breakdown_history(2).counts_by_size(4)); 134 EXPECT_EQ(25U, new_report.alloc_breakdown_history(2).counts_by_size(4));
141 EXPECT_EQ(26U, new_report.alloc_breakdown_history(2).count_for_call_stack()); 135 EXPECT_EQ(26U, new_report.alloc_breakdown_history(2).count_for_call_stack());
142 } 136 }
143 137
144 } // namespace leak_detector 138 } // namespace leak_detector
145 } // namespace metrics 139 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/leak_detector/protobuf_to_mojo_converter.cc ('k') | components/metrics/proto/memory_leak_report.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698