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

Side by Side Diff: testing/perf/scoped_histogram_result_printer_unittest.cc

Issue 2300323003: Adding performance tests for HQP that represent importance of optimising HistoryItemsForTerms method (Closed)
Patch Set: Created 4 years, 3 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
(Empty)
1 // Copyright (c) 2016 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 "testing/perf/scoped_histogram_result_printer.h"
6
7 #include "base/metrics/histogram_macros.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest-spi.h"
10
11 namespace {
12 using testing::_;
13
14 const char kFakeHistogram[] = "FakeHistogramName";
15 const char kFakeMeasurement[] = "FakeMeasurement";
16
17 struct MockedPrinter {
18 MOCK_METHOD2(PrintHistogram,
19 void(const base::HistogramSamples&, const std::string&));
20 perf_test::HistogramPrinter GetCallback() {
21 return base::Bind(&MockedPrinter::PrintHistogram, base::Unretained(this));
22 }
23 };
24
25 void StrictIsNotFoundTest() {
26 MockedPrinter perf_printer;
27 EXPECT_CALL(perf_printer, PrintHistogram(_, _)).Times(0);
28
29 perf_test::ScopedHistogramResultPrinter scoped_printer(
30 perf_printer.GetCallback());
31
32 scoped_printer.AddHistogramStrict(kFakeHistogram, kFakeMeasurement);
33 }
34
35 void NothingIsAddedToStrictTest() {
36 MockedPrinter perf_printer;
37 EXPECT_CALL(perf_printer, PrintHistogram(_, _)).Times(0);
38
39 { SCOPED_UMA_HISTOGRAM_TIMER(kFakeHistogram); }
40
41 perf_test::ScopedHistogramResultPrinter scoped_printer(
42 perf_printer.GetCallback());
43
44 scoped_printer.AddHistogramStrict(kFakeHistogram, kFakeMeasurement);
45 }
46
47 } // namespace
48
49 namespace perf_test {
50
51 class ScopedHistogramResultPrinterTest : public testing::Test {};
52
53 TEST_F(ScopedHistogramResultPrinterTest, StrictIsNotFound) {
54 EXPECT_NONFATAL_FAILURE(StrictIsNotFoundTest(), " wasn't found");
55 }
56
57 TEST_F(ScopedHistogramResultPrinterTest, StrictIsFound) {
58 MockedPrinter perf_printer;
59 EXPECT_CALL(perf_printer, PrintHistogram(_, _));
60
61 ScopedHistogramResultPrinter scoped_printer(perf_printer.GetCallback());
62
63 scoped_printer.AddHistogramStrict(kFakeHistogram, kFakeMeasurement);
64 SCOPED_UMA_HISTOGRAM_TIMER(kFakeHistogram);
65 }
66
67 TEST_F(ScopedHistogramResultPrinterTest, NothingIsAddedToStrict) {
68 EXPECT_NONFATAL_FAILURE(NothingIsAddedToStrictTest(),
69 "Nothing was added in ");
70 }
71
72 TEST_F(ScopedHistogramResultPrinterTest, NiceIsNotFound) {
73 MockedPrinter perf_printer;
74 EXPECT_CALL(perf_printer, PrintHistogram(_, _)).Times(0);
75
76 ScopedHistogramResultPrinter scoped_printer(perf_printer.GetCallback());
77
78 scoped_printer.AddHistogramNice(kFakeHistogram, kFakeMeasurement);
79 }
80
81 TEST_F(ScopedHistogramResultPrinterTest, NothingIsAddedToNice) {
82 MockedPrinter perf_printer;
83 EXPECT_CALL(perf_printer, PrintHistogram(_, _)).Times(0);
84
85 { SCOPED_UMA_HISTOGRAM_TIMER(kFakeHistogram); }
86 ScopedHistogramResultPrinter scoped_printer(perf_printer.GetCallback());
87 scoped_printer.AddHistogramNice(kFakeHistogram, kFakeMeasurement);
88 }
89
90 } // namespace perf_test
OLDNEW
« chrome/test/base/ui_test_utils.cc ('K') | « testing/perf/scoped_histogram_result_printer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698