Page Speed Optimization Libraries  1.13.35.1
 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 
31 namespace net_instaweb {
32 
33 template<class OptionsClass>
35  public:
37  public:
38  explicit CustomTestRewriteDriverFactory(MockUrlFetcher* url_fetcher)
39  : TestRewriteDriverFactory(process_context(), GTestTempDir(),
40  url_fetcher) {
42  }
43 
44  virtual OptionsClass* NewRewriteOptions() {
45  return new OptionsClass(thread_system());
46  }
47  };
48 
50  : RewriteTestBase(MakeFactories(&mock_url_fetcher_)) {
51  }
52 
53  virtual ~CustomRewriteTestBase() {
54  OptionsClass::Terminate();
55  }
56 
59  }
60 
61  OptionsClass* NewOptions() {
62  return new OptionsClass(factory()->thread_system());
63  }
64 
66  OptionsClass* options() { return static_cast<OptionsClass*>(options_); }
67 
68  private:
71  static std::pair<TestRewriteDriverFactory*, TestRewriteDriverFactory*>
72  MakeFactories(MockUrlFetcher* mock_fetcher) {
73  OptionsClass::Initialize();
74 
75  return make_pair(
76  new CustomTestRewriteDriverFactory(mock_fetcher),
77  new CustomTestRewriteDriverFactory(mock_fetcher));
78  }
79 };
80 
81 }
82 
83 #endif
Definition: test_rewrite_driver_factory.h:67
static const ProcessContext & process_context()
Definition: rewrite_test_base.h:90
virtual OptionsClass * NewRewriteOptions()
Note that this disables ajax rewriting by default.
Definition: custom_rewrite_test_base.h:44
virtual TestRewriteDriverFactory * MakeTestFactory()
Definition: custom_rewrite_test_base.h:57
RewriteOptions * options_
owned by rewrite_driver_.
Definition: rewrite_test_base.h:845
Definition: mock_url_fetcher.h:41
MockUrlFetcher mock_url_fetcher_
Definition: rewrite_test_base.h:822
OptionsClass * options()
Non-virtual override of options method defined in RewriteTestBase.
Definition: custom_rewrite_test_base.h:66
Definition: custom_rewrite_test_base.h:34