Skip to content

Commit 5e4032d

Browse files
committed
metrics: Fix build error in tests and apply formatting
1 parent 51ef750 commit 5e4032d

File tree

2 files changed

+21
-44
lines changed

2 files changed

+21
-44
lines changed

cobalt/browser/metrics/cobalt_metrics_service_client_test.cc

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ class TestProcessMemoryMetricsEmitter : public CobaltMemoryMetricsEmitter {
8181
malloc_dump->numeric_entries["allocated_objects_size"] = 8 * 1024 * 1024;
8282
browser_dump->chrome_allocator_dumps["malloc"] = std::move(malloc_dump);
8383

84+
// Add Skia Glyph Cache dump
85+
auto skia_dump = memory_instrumentation::mojom::AllocatorMemDump::New();
86+
skia_dump->numeric_entries["size"] = 2 * 1024 * 1024;
87+
browser_dump->chrome_allocator_dumps["skia/sk_glyph_cache"] =
88+
std::move(skia_dump);
89+
90+
// Add Font Caches dump
91+
auto font_dump = memory_instrumentation::mojom::AllocatorMemDump::New();
92+
font_dump->numeric_entries["size"] = 512 * 1024;
93+
browser_dump->chrome_allocator_dumps["font_caches/shape_caches"] =
94+
std::move(font_dump);
95+
8496
dump_ptr->process_dumps.push_back(std::move(browser_dump));
8597

8698
auto global_dump =
@@ -368,48 +380,12 @@ TEST_F(CobaltMetricsServiceClientTest, RecordMemoryMetricsRecordsHistogram) {
368380
.GetAllSamples("Memory.Experimental.Browser2.Malloc.AllocatedObjects")
369381
.size(),
370382
1u);
371-
}
372-
373-
TEST_F(CobaltMetricsServiceClientTest,
374-
RecordMemoryMetricsRecordsExperimentalHistograms) {
375-
base::HistogramTester histogram_tester;
376-
377-
memory_instrumentation::mojom::GlobalMemoryDumpPtr dump_ptr =
378-
memory_instrumentation::mojom::GlobalMemoryDump::New();
379-
380-
auto process_dump = memory_instrumentation::mojom::ProcessMemoryDump::New();
381-
process_dump->process_type =
382-
memory_instrumentation::mojom::ProcessType::BROWSER;
383-
process_dump->os_dump = memory_instrumentation::mojom::OSMemDump::New();
384383

385-
// 2MB in bytes
386-
const uint64_t kSkiaGlyphCacheSize = 2 * 1024 * 1024;
387-
// 512KB in bytes
388-
const uint64_t kFontCacheSize = 512 * 1024;
389-
390-
auto skia_dump = memory_instrumentation::mojom::AllocatorMemDump::New();
391-
skia_dump->numeric_entries["size"] = kSkiaGlyphCacheSize;
392-
process_dump->chrome_allocator_dumps["skia/sk_glyph_cache"] =
393-
std::move(skia_dump);
394-
395-
auto font_dump = memory_instrumentation::mojom::AllocatorMemDump::New();
396-
font_dump->numeric_entries["size"] = kFontCacheSize;
397-
process_dump->chrome_allocator_dumps["font_caches/shape_caches"] =
398-
std::move(font_dump);
399-
400-
dump_ptr->process_dumps.push_back(std::move(process_dump));
401-
402-
auto global_dump =
403-
memory_instrumentation::GlobalMemoryDump::MoveFrom(std::move(dump_ptr));
404-
405-
CobaltMetricsServiceClient::RecordMemoryMetrics(global_dump.get());
406-
407-
// Values should be in KB
384+
// Experimental histograms (now with .Small. suffix in KB)
385+
histogram_tester.ExpectUniqueSample(
386+
"Memory.Experimental.Browser2.Skia.Small.SkGlyphCache", 2048, 1);
408387
histogram_tester.ExpectUniqueSample(
409-
"Memory.Experimental.Browser2.Skia.SkGlyphCache",
410-
kSkiaGlyphCacheSize / 1024, 1);
411-
histogram_tester.ExpectUniqueSample("Memory.Experimental.Browser2.FontCaches",
412-
kFontCacheSize / 1024, 1);
388+
"Memory.Experimental.Browser2.Small.FontCaches", 512, 1);
413389
}
414390

415391
TEST_F(CobaltMetricsServiceClientTest,

cobalt/browser/metrics/font_metrics_browsertest.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ IN_PROC_BROWSER_TEST_F(FontMetricsBrowserTest, RecordsFontHistograms) {
8585
.size(),
8686
1u);
8787

88-
EXPECT_GE(histogram_tester
89-
.GetAllSamples("Memory.Experimental.Browser2.Skia.Small.SkGlyphCache")
90-
.size(),
91-
1u);
88+
EXPECT_GE(
89+
histogram_tester
90+
.GetAllSamples("Memory.Experimental.Browser2.Skia.Small.SkGlyphCache")
91+
.size(),
92+
1u);
9293

9394
EXPECT_GE(
9495
histogram_tester.GetAllSamples("Memory.Experimental.Browser2.FontCaches")

0 commit comments

Comments
 (0)