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

Side by Side Diff: base/trace_event/process_memory_totals_dump_provider_unittest.cc

Issue 1546033002: Switch to standard integer types in base/trace_event/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 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/process_memory_totals_dump_provider.h" 5 #include "base/trace_event/process_memory_totals_dump_provider.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/trace_event/process_memory_dump.h" 10 #include "base/trace_event/process_memory_dump.h"
8 #include "base/trace_event/process_memory_totals.h" 11 #include "base/trace_event/process_memory_totals.h"
9 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
10 13
11 namespace base { 14 namespace base {
12 namespace trace_event { 15 namespace trace_event {
13 16
14 TEST(ProcessMemoryTotalsDumpProviderTest, DumpRSS) { 17 TEST(ProcessMemoryTotalsDumpProviderTest, DumpRSS) {
15 const MemoryDumpArgs high_detail_args = {MemoryDumpLevelOfDetail::DETAILED}; 18 const MemoryDumpArgs high_detail_args = {MemoryDumpLevelOfDetail::DETAILED};
16 auto pmtdp = ProcessMemoryTotalsDumpProvider::GetInstance(); 19 auto pmtdp = ProcessMemoryTotalsDumpProvider::GetInstance();
17 scoped_ptr<ProcessMemoryDump> pmd_before(new ProcessMemoryDump(nullptr)); 20 scoped_ptr<ProcessMemoryDump> pmd_before(new ProcessMemoryDump(nullptr));
18 scoped_ptr<ProcessMemoryDump> pmd_after(new ProcessMemoryDump(nullptr)); 21 scoped_ptr<ProcessMemoryDump> pmd_after(new ProcessMemoryDump(nullptr));
19 22
20 ProcessMemoryTotalsDumpProvider::rss_bytes_for_testing = 1024; 23 ProcessMemoryTotalsDumpProvider::rss_bytes_for_testing = 1024;
21 pmtdp->OnMemoryDump(high_detail_args, pmd_before.get()); 24 pmtdp->OnMemoryDump(high_detail_args, pmd_before.get());
22 25
23 // Pretend that the RSS of the process increased of +1M. 26 // Pretend that the RSS of the process increased of +1M.
24 const size_t kAllocSize = 1048576; 27 const size_t kAllocSize = 1048576;
25 ProcessMemoryTotalsDumpProvider::rss_bytes_for_testing += kAllocSize; 28 ProcessMemoryTotalsDumpProvider::rss_bytes_for_testing += kAllocSize;
26 29
27 pmtdp->OnMemoryDump(high_detail_args, pmd_after.get()); 30 pmtdp->OnMemoryDump(high_detail_args, pmd_after.get());
28 31
29 ProcessMemoryTotalsDumpProvider::rss_bytes_for_testing = 0; 32 ProcessMemoryTotalsDumpProvider::rss_bytes_for_testing = 0;
30 33
31 ASSERT_TRUE(pmd_before->has_process_totals()); 34 ASSERT_TRUE(pmd_before->has_process_totals());
32 ASSERT_TRUE(pmd_after->has_process_totals()); 35 ASSERT_TRUE(pmd_after->has_process_totals());
33 36
34 const uint64 rss_before = pmd_before->process_totals()->resident_set_bytes(); 37 const uint64_t rss_before =
35 const uint64 rss_after = pmd_after->process_totals()->resident_set_bytes(); 38 pmd_before->process_totals()->resident_set_bytes();
39 const uint64_t rss_after = pmd_after->process_totals()->resident_set_bytes();
36 40
37 EXPECT_NE(0U, rss_before); 41 EXPECT_NE(0U, rss_before);
38 EXPECT_NE(0U, rss_after); 42 EXPECT_NE(0U, rss_after);
39 43
40 EXPECT_EQ(rss_after - rss_before, kAllocSize); 44 EXPECT_EQ(rss_after - rss_before, kAllocSize);
41 } 45 }
42 46
43 } // namespace trace_event 47 } // namespace trace_event
44 } // namespace base 48 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/process_memory_totals_dump_provider.cc ('k') | base/trace_event/trace_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698