Page Speed Optimization Libraries  1.9.32.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
custom_rewrite_test_base.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
17 
20 
21 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CUSTOM_REWRITE_TEST_BASE_H_
22 #define NET_INSTAWEB_REWRITER_PUBLIC_CUSTOM_REWRITE_TEST_BASE_H_
23 
24 #include <utility>
25 
30 #include "pagespeed/kernel/base/gtest.h"
31 
32 namespace net_instaweb {
33 
34 template<class OptionsClass>
36  public:
38  public:
40  MockUrlFetcher* url_fetcher,
41  TestDistributedFetcher* distributed_fetcher)
42  : TestRewriteDriverFactory(process_context(), GTestTempDir(),
43  url_fetcher, distributed_fetcher) {
45  }
46 
47  virtual OptionsClass* NewRewriteOptions() {
48  return new OptionsClass(thread_system());
49  }
50  };
51 
53  : RewriteTestBase(MakeFactories(&mock_url_fetcher_,
54  &test_distributed_fetcher_)) {
55  }
56 
57  virtual ~CustomRewriteTestBase() {
58  OptionsClass::Terminate();
59  }
60 
63  &test_distributed_fetcher_);
64  }
65 
66  OptionsClass* NewOptions() {
67  return new OptionsClass(factory()->thread_system());
68  }
69 
70  private:
73  static std::pair<TestRewriteDriverFactory*, TestRewriteDriverFactory*>
74  MakeFactories(MockUrlFetcher* mock_fetcher,
75  TestDistributedFetcher* test_distributed_fetcher) {
76  OptionsClass::Initialize();
77 
78  return make_pair(
79  new CustomTestRewriteDriverFactory(mock_fetcher,
80  test_distributed_fetcher),
81  new CustomTestRewriteDriverFactory(mock_fetcher,
82  test_distributed_fetcher));
83  }
84 };
85 
86 }
87 
88 #endif
Definition: test_rewrite_driver_factory.h:67
static const ProcessContext & process_context()
Definition: rewrite_test_base.h:89
virtual OptionsClass * NewRewriteOptions()
Note that this disables ajax rewriting by default.
Definition: custom_rewrite_test_base.h:47
virtual TestRewriteDriverFactory * MakeTestFactory()
Definition: custom_rewrite_test_base.h:61
Definition: test_distributed_fetcher.h:37
Definition: mock_url_fetcher.h:41
MockUrlFetcher mock_url_fetcher_
Definition: rewrite_test_base.h:765
Definition: custom_rewrite_test_base.h:35