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

Side by Side Diff: chrome/browser/metrics/metrics_memory_details_browsertest.cc

Issue 823533004: Move memory histograms generation to MetricsMemoryDetails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better class comment. Created 5 years, 11 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
« no previous file with comments | « chrome/browser/metrics/metrics_memory_details.cc ('k') | chrome/browser/ui/webui/about_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/memory_details.h" 5 #include "chrome/browser/metrics/metrics_memory_details.h"
6 6
7 #include "base/bind_helpers.h"
7 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
8 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
9 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
10 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
11 12
12 namespace { 13 namespace {
13 14
14 class TestMemoryDetails : public MemoryDetails { 15 class TestMemoryDetails : public MetricsMemoryDetails {
15 public: 16 public:
16 TestMemoryDetails() {} 17 TestMemoryDetails()
18 : MetricsMemoryDetails(base::Bind(&base::DoNothing), nullptr) {}
17 19
18 void StartFetchAndWait() { 20 void StartFetchAndWait() {
19 StartFetch(UPDATE_USER_METRICS); 21 StartFetch();
20 content::RunMessageLoop(); 22 content::RunMessageLoop();
21 } 23 }
22 24
23 private: 25 private:
24 ~TestMemoryDetails() override {} 26 ~TestMemoryDetails() override {}
25 27
26 void OnDetailsAvailable() override { 28 void OnDetailsAvailable() override {
29 MetricsMemoryDetails::OnDetailsAvailable();
27 // Exit the loop initiated by StartFetchAndWait(). 30 // Exit the loop initiated by StartFetchAndWait().
28 base::MessageLoop::current()->Quit(); 31 base::MessageLoop::current()->Quit();
29 } 32 }
30 33
31 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails); 34 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails);
32 }; 35 };
33 36
34 } // namespace 37 } // namespace
35 38
36 class MemoryDetailsBrowserTest : public InProcessBrowserTest { 39 class MetricsMemoryDetailsBrowserTest : public InProcessBrowserTest {
37 public: 40 public:
38 MemoryDetailsBrowserTest() {} 41 MetricsMemoryDetailsBrowserTest() {}
39 ~MemoryDetailsBrowserTest() override {} 42 ~MetricsMemoryDetailsBrowserTest() override {}
40 43
41 private: 44 private:
42 DISALLOW_COPY_AND_ASSIGN(MemoryDetailsBrowserTest); 45 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetailsBrowserTest);
43 }; 46 };
44 47
45 IN_PROC_BROWSER_TEST_F(MemoryDetailsBrowserTest, TestMemoryDetails) { 48 IN_PROC_BROWSER_TEST_F(MetricsMemoryDetailsBrowserTest, TestMemoryDetails) {
46 base::HistogramTester histogram_tester; 49 base::HistogramTester histogram_tester;
47 50
48 scoped_refptr<TestMemoryDetails> details(new TestMemoryDetails); 51 scoped_refptr<TestMemoryDetails> details(new TestMemoryDetails);
49 details->StartFetchAndWait(); 52 details->StartFetchAndWait();
50 53
51 // Memory.Browser histogram should have a single non-0 sample recorded. 54 // Memory.Browser histogram should have a single non-0 sample recorded.
52 histogram_tester.ExpectTotalCount("Memory.Browser", 1); 55 histogram_tester.ExpectTotalCount("Memory.Browser", 1);
53 scoped_ptr<base::HistogramSamples> samples( 56 scoped_ptr<base::HistogramSamples> samples(
54 histogram_tester.GetHistogramSamplesSinceCreation("Memory.Browser")); 57 histogram_tester.GetHistogramSamplesSinceCreation("Memory.Browser"));
55 ASSERT_TRUE(samples); 58 ASSERT_TRUE(samples);
56 EXPECT_NE(0, samples->sum()); 59 EXPECT_NE(0, samples->sum());
57 } 60 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_memory_details.cc ('k') | chrome/browser/ui/webui/about_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698