Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mock_callback.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 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  */
16 
18 
20 
21 #ifndef NET_INSTAWEB_HTTP_PUBLIC_MOCK_CALLBACK_H_
22 #define NET_INSTAWEB_HTTP_PUBLIC_MOCK_CALLBACK_H_
23 
25 #include "net/instaweb/http/public/request_context.h"
28 
29 namespace net_instaweb {
30 
35  public:
36  ExpectStringAsyncFetch(bool expect_success,
38  : StringAsyncFetch(request_context), expect_success_(expect_success) {}
39  virtual ~ExpectStringAsyncFetch() {
40  EXPECT_TRUE(done());
41  }
42 
43  virtual void HandleDone(bool success) {
44  EXPECT_FALSE(done()) << "Already Done; perhaps you reused without Reset()";
45  StringAsyncFetch::HandleDone(success);
46  EXPECT_EQ(expect_success_, success);
47  }
48 
49  void set_expect_success(bool x) { expect_success_ = x; }
50 
51  private:
52  bool expect_success_;
53 
54 
55 };
56 
57 }
58 
59 #endif
Definition: mock_callback.h:34
virtual const RequestContextPtr & request_context()
Definition: async_fetch.h:151
Definition: async_fetch.h:192