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

Side by Side Diff: chrome/browser/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/memory_details_android.cc ('k') | chrome/browser/memory_details_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/memory_details.h"
6
7 #include "base/message_loop/message_loop.h"
8 #include "base/test/histogram_tester.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "content/public/test/test_utils.h"
11
12 namespace {
13
14 class TestMemoryDetails : public MemoryDetails {
15 public:
16 TestMemoryDetails() {}
17
18 void StartFetchAndWait() {
19 StartFetch(UPDATE_USER_METRICS);
20 content::RunMessageLoop();
21 }
22
23 private:
24 ~TestMemoryDetails() override {}
25
26 void OnDetailsAvailable() override {
27 // Exit the loop initiated by StartFetchAndWait().
28 base::MessageLoop::current()->Quit();
29 }
30
31 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails);
32 };
33
34 } // namespace
35
36 class MemoryDetailsBrowserTest : public InProcessBrowserTest {
37 public:
38 MemoryDetailsBrowserTest() {}
39 ~MemoryDetailsBrowserTest() override {}
40
41 private:
42 DISALLOW_COPY_AND_ASSIGN(MemoryDetailsBrowserTest);
43 };
44
45 IN_PROC_BROWSER_TEST_F(MemoryDetailsBrowserTest, TestMemoryDetails) {
46 base::HistogramTester histogram_tester;
47
48 scoped_refptr<TestMemoryDetails> details(new TestMemoryDetails);
49 details->StartFetchAndWait();
50
51 // Memory.Browser histogram should have a single non-0 sample recorded.
52 histogram_tester.ExpectTotalCount("Memory.Browser", 1);
53 scoped_ptr<base::HistogramSamples> samples(
54 histogram_tester.GetHistogramSamplesSinceCreation("Memory.Browser"));
55 ASSERT_TRUE(samples);
56 EXPECT_NE(0, samples->sum());
57 }
OLDNEW
« no previous file with comments | « chrome/browser/memory_details_android.cc ('k') | chrome/browser/memory_details_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698