Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shared_mem_statistics_test_base.h
Go to the documentation of this file.
1 // Copyright 2011 Google Inc.
16 
17 #ifndef PAGESPEED_KERNEL_SHAREDMEM_SHARED_MEM_STATISTICS_TEST_BASE_H_
18 #define PAGESPEED_KERNEL_SHAREDMEM_SHARED_MEM_STATISTICS_TEST_BASE_H_
19 
31 
32 namespace net_instaweb {
33 
34 class StatisticsLogger;
35 
36 class SharedMemStatisticsTestBase : public testing::Test {
37  protected:
38  typedef void (SharedMemStatisticsTestBase::*TestMethod)();
39 
40  static const int64 kLogIntervalMs;
41  static const int64 kMaxLogfileSizeKb;
42 
45 
46  virtual void SetUp();
47  virtual void TearDown();
48  bool CreateChild(TestMethod method);
49 
50  void TestCreate();
51  void TestSet();
52  void TestClear();
53  void TestAdd();
54  void TestSetReturningPrevious();
55  void TestHistogram();
56  void TestHistogramRender();
57  void TestHistogramNoExtraClear();
58  void TestHistogramExtremeBuckets();
59  void TestTimedVariableEmulation();
60  void TestConsoleStatisticsLogger();
61 
62  StatisticsLogger* console_logger() const {
63  return stats_->console_logger_.get();
64  }
65 
66  scoped_ptr<ThreadSystem> thread_system_;
67  MockMessageHandler handler_;
68  scoped_ptr<MemFileSystem> file_system_;
70 
71  private:
72  void TestCreateChild();
73  void TestSetChild();
74  void TestClearChild();
75  void TestHistogramNoExtraClearChild();
76 
78  void TestAddChild();
79  bool AddVars(SharedMemStatistics* stats);
80  bool AddHistograms(SharedMemStatistics* stats);
83  bool Contains(const StringPiece& html, const StringPiece& pattern);
84 
85  SharedMemStatistics* ChildInit();
86  void ParentInit();
87 
89  scoped_ptr<AbstractSharedMem> shmem_runtime_;
90  scoped_ptr<MockTimer> timer_;
91 
92 
93 };
94 
95 template<typename ConcreteTestEnv>
97  public:
99  : SharedMemStatisticsTestBase(new ConcreteTestEnv) {
100  }
101 };
102 
103 TYPED_TEST_CASE_P(SharedMemStatisticsTestTemplate);
104 
105 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestCreate) {
106  SharedMemStatisticsTestBase::TestCreate();
107 }
108 
109 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestSet) {
110  SharedMemStatisticsTestBase::TestSet();
111 }
112 
113 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestClear) {
114  SharedMemStatisticsTestBase::TestClear();
115 }
116 
117 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestAdd) {
118  SharedMemStatisticsTestBase::TestAdd();
119 }
120 
121 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestSetReturningPrevious) {
122  SharedMemStatisticsTestBase::TestSetReturningPrevious();
123 }
124 
125 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestHistogram) {
126  SharedMemStatisticsTestBase::TestHistogram();
127 }
128 
129 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestHistogramRender) {
130  SharedMemStatisticsTestBase::TestHistogramRender();
131 }
132 
133 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestHistogramExtremeBuckets) {
134  SharedMemStatisticsTestBase::TestHistogramExtremeBuckets();
135 }
136 
137 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestHistogramNoExtraClear) {
138  SharedMemStatisticsTestBase::TestHistogramNoExtraClear();
139 }
140 
141 TYPED_TEST_P(SharedMemStatisticsTestTemplate, TestTimedVariableEmulation) {
142  SharedMemStatisticsTestBase::TestTimedVariableEmulation();
143 }
144 
145 REGISTER_TYPED_TEST_CASE_P(SharedMemStatisticsTestTemplate, TestCreate,
146  TestSet, TestClear, TestAdd,
147  TestSetReturningPrevious,
148  TestHistogram, TestHistogramRender,
149  TestHistogramNoExtraClear,
150  TestHistogramExtremeBuckets,
151  TestTimedVariableEmulation);
152 
153 }
154 
155 #endif
scoped_ptr< SharedMemStatistics > stats_
(the parent process version)
Definition: shared_mem_statistics_test_base.h:69
Definition: shared_mem_statistics.h:182
Definition: shared_mem_statistics_test_base.h:96
Definition: mock_message_handler.h:39
Definition: scoped_ptr.h:30
Definition: shared_mem_statistics_test_base.h:36
Definition: shared_mem_test_base.h:33
Definition: statistics_logger.h:42