Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / metrics / metrics_memory_details_browsertest.cc
blobd38bfda6c6ea11c221fc75ab99747acb8e6bde9d
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.
5 #include "chrome/browser/metrics/metrics_memory_details.h"
7 #include "base/bind_helpers.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/test/histogram_tester.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "content/public/test/test_utils.h"
13 namespace {
15 class TestMemoryDetails : public MetricsMemoryDetails {
16 public:
17 TestMemoryDetails()
18 : MetricsMemoryDetails(base::Bind(&base::DoNothing), nullptr) {}
20 void StartFetchAndWait() {
21 StartFetch(FROM_CHROME_ONLY);
22 content::RunMessageLoop();
25 private:
26 ~TestMemoryDetails() override {}
28 void OnDetailsAvailable() override {
29 MetricsMemoryDetails::OnDetailsAvailable();
30 // Exit the loop initiated by StartFetchAndWait().
31 base::MessageLoop::current()->Quit();
34 DISALLOW_COPY_AND_ASSIGN(TestMemoryDetails);
37 } // namespace
39 class MetricsMemoryDetailsBrowserTest : public InProcessBrowserTest {
40 public:
41 MetricsMemoryDetailsBrowserTest() {}
42 ~MetricsMemoryDetailsBrowserTest() override {}
44 private:
45 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetailsBrowserTest);
48 IN_PROC_BROWSER_TEST_F(MetricsMemoryDetailsBrowserTest, TestMemoryDetails) {
49 base::HistogramTester histogram_tester;
51 scoped_refptr<TestMemoryDetails> details(new TestMemoryDetails);
52 details->StartFetchAndWait();
54 // Memory.Browser histogram should have a single non-0 sample recorded.
55 histogram_tester.ExpectTotalCount("Memory.Browser", 1);
56 scoped_ptr<base::HistogramSamples> samples(
57 histogram_tester.GetHistogramSamplesSinceCreation("Memory.Browser"));
58 ASSERT_TRUE(samples);
59 EXPECT_NE(0, samples->sum());