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

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: clang-format 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
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/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "content/public/test/test_utils.h" 10 #include "content/public/test/test_utils.h"
11 11
12 namespace { 12 namespace {
13 13
14 class TestMemoryDetails : public MemoryDetails { 14 void DoNothing() {
15 }
Ilya Sherman 2015/01/16 04:57:36 FWIW, this is also defined in base/bind_helpers.h.
Alexei Svitkine (slow) 2015/01/16 16:07:50 Done.
16
17 class TestMemoryDetails : public MetricsMemoryDetails {
15 public: 18 public:
16 TestMemoryDetails() {} 19 TestMemoryDetails() : MetricsMemoryDetails(base::Bind(&DoNothing), nullptr) {}
17 20
18 void StartFetchAndWait() { 21 void StartFetchAndWait() {
19 StartFetch(UPDATE_USER_METRICS); 22 StartFetch();
20 content::RunMessageLoop(); 23 content::RunMessageLoop();
21 } 24 }
22 25
23 private: 26 private:
24 ~TestMemoryDetails() override {} 27 ~TestMemoryDetails() override {}
25 28
26 void OnDetailsAvailable() override { 29 void OnDetailsAvailable() override {
30 MetricsMemoryDetails::OnDetailsAvailable();
27 // Exit the loop initiated by StartFetchAndWait(). 31 // Exit the loop initiated by StartFetchAndWait().
28 base::MessageLoop::current()->Quit(); 32 base::MessageLoop::current()->Quit();
29 } 33 }
30 34
31 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails); 35 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails);
32 }; 36 };
33 37
34 } // namespace 38 } // namespace
35 39
36 class MemoryDetailsBrowserTest : public InProcessBrowserTest { 40 class MetricsMemoryDetailsBrowserTest : public InProcessBrowserTest {
37 public: 41 public:
38 MemoryDetailsBrowserTest() {} 42 MetricsMemoryDetailsBrowserTest() {}
39 ~MemoryDetailsBrowserTest() override {} 43 ~MetricsMemoryDetailsBrowserTest() override {}
40 44
41 private: 45 private:
42 DISALLOW_COPY_AND_ASSIGN(MemoryDetailsBrowserTest); 46 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetailsBrowserTest);
43 }; 47 };
44 48
45 IN_PROC_BROWSER_TEST_F(MemoryDetailsBrowserTest, TestMemoryDetails) { 49 IN_PROC_BROWSER_TEST_F(MetricsMemoryDetailsBrowserTest, TestMemoryDetails) {
46 base::HistogramTester histogram_tester; 50 base::HistogramTester histogram_tester;
47 51
48 scoped_refptr<TestMemoryDetails> details(new TestMemoryDetails); 52 scoped_refptr<TestMemoryDetails> details(new TestMemoryDetails);
49 details->StartFetchAndWait(); 53 details->StartFetchAndWait();
50 54
51 // Memory.Browser histogram should have a single non-0 sample recorded. 55 // Memory.Browser histogram should have a single non-0 sample recorded.
52 histogram_tester.ExpectTotalCount("Memory.Browser", 1); 56 histogram_tester.ExpectTotalCount("Memory.Browser", 1);
53 scoped_ptr<base::HistogramSamples> samples( 57 scoped_ptr<base::HistogramSamples> samples(
54 histogram_tester.GetHistogramSamplesSinceCreation("Memory.Browser")); 58 histogram_tester.GetHistogramSamplesSinceCreation("Memory.Browser"));
55 ASSERT_TRUE(samples); 59 ASSERT_TRUE(samples);
56 EXPECT_NE(0, samples->sum()); 60 EXPECT_NE(0, samples->sum());
57 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698