• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 #ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_UTILS_H_
6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_UTILS_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/macros.h"
12 
13 namespace base {
14 class HistogramSamples;
15 }
16 
17 namespace chromeos {
18 
19 // Checks enum values in a histogram.
20 class EnumHistogramChecker {
21  public:
22   EnumHistogramChecker(const std::string& histogram, int count,
23                        base::HistogramSamples* base);
24   ~EnumHistogramChecker();
25 
26   // Sets expectation for a given enum key. |key| must be between 0
27   // and expect_.size().
28   EnumHistogramChecker* Expect(int key, int value);
29 
30   // Actually accesses histogram and checks values for all keys.
31   bool Check();
32 
33  private:
34   // Name of a histogram.
35   std::string histogram_;
36 
37   // List of expectations.
38   std::vector<int> expect_;
39 
40   // When not NULL, expected values are compared with actual values
41   // minus base.
42   base::HistogramSamples* base_;
43 
44   DISALLOW_COPY_AND_ASSIGN(EnumHistogramChecker);
45 };
46 
47 }  // namespace chromeos
48 
49 #endif  // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_TEST_UTILS_H_
50