Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
log_record_test_helper.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  */
16 
18 
19 #ifndef PAGESPEED_OPT_LOGGING_LOG_RECORD_TEST_HELPER_H_
20 #define PAGESPEED_OPT_LOGGING_LOG_RECORD_TEST_HELPER_H_
21 
24 #include "pagespeed/kernel/http/image_types.pb.h"
25 #include "pagespeed/opt/logging/enums.pb.h"
28 
29 using ::testing::_;
30 using ::testing::Matcher;
31 using ::testing::StrEq;
32 
33 namespace net_instaweb {
34 
35 class AbstractMutex;
36 
41  const char* id,
42  const GoogleString& url,
43  RewriterApplication::Status status,
44  bool is_image_inlined,
45  bool is_critical_image,
46  bool is_url_rewritten,
47  int size,
48  bool try_low_res_src_insertion,
49  bool low_res_src_inserted,
50  ImageType low_res_image_type,
51  int low_res_data_size) :
52  id_(id), url_(url), status_(status), is_image_inlined_(is_image_inlined),
53  is_critical_image_(is_critical_image), is_url_rewritten_(is_url_rewritten),
54  size_(size), try_low_res_src_insertion_(try_low_res_src_insertion),
55  low_res_src_inserted_(low_res_src_inserted),
56  low_res_image_type_(low_res_image_type),
57  low_res_data_size_(low_res_data_size) {}
58 
59  const char* id_;
60  GoogleString url_;
61  RewriterApplication::Status status_;
62  bool is_image_inlined_;
63  bool is_critical_image_;
64  bool is_url_rewritten_;
65  int size_;
66  bool try_low_res_src_insertion_;
67  bool low_res_src_inserted_;
68  ImageType low_res_image_type_;
69  int low_res_data_size_;
70 };
71 
74 Matcher<ImageRewriteInfo> LogImageRewriteActivityMatcher(
75  Matcher<const char*> id,
76  Matcher<const GoogleString&> url,
77  Matcher<RewriterApplication::Status> status,
78  Matcher<bool> is_image_inlined,
79  Matcher<bool> is_critical_image,
80  Matcher<bool> is_url_rewritten,
81  Matcher<int> size,
82  Matcher<bool> try_low_res_src_insertion,
83  Matcher<bool> low_res_src_inserted,
84  Matcher<ImageType> low_res_image_type,
85  Matcher<int> low_res_data_size);
86 
88 class MockLogRecord : public LogRecord {
89  public:
90  explicit MockLogRecord(AbstractMutex* mutex) : LogRecord(mutex) {}
91  ~MockLogRecord() {}
93  const char* id,
94  const GoogleString& url,
95  RewriterApplication::Status status,
96  bool is_image_inlined,
97  bool is_critical_image,
98  bool is_url_rewritten,
99  int size,
100  bool try_low_res_src_insertion,
101  bool low_res_src_inserted,
102  ImageType low_res_image_type,
103  int low_res_data_size) {
104  ImageRewriteInfo info(id, url, status, is_image_inlined, is_critical_image,
105  is_url_rewritten, size, try_low_res_src_insertion,
106  low_res_src_inserted, low_res_image_type,
107  low_res_data_size);
108  MockLogImageRewriteActivity(info);
109  }
110  MOCK_METHOD1(MockLogImageRewriteActivity, void(ImageRewriteInfo));
111 };
112 
113 }
114 
115 #endif
Simple AbstractLogRecord implementation which owns a LoggingInfo protobuf.
Definition: log_record.h:294
virtual void LogImageRewriteActivity(const char *id, const GoogleString &url, RewriterApplication::Status status, bool is_image_inlined, bool is_critical_image, bool is_url_rewritten, int size, bool try_low_res_src_insertion, bool low_res_src_inserted, ImageType low_res_image_type, int low_res_data_size)
Log a RewriterInfo for the image rewrite filter.
Definition: log_record_test_helper.h:92
Abstract interface for implementing a mutex.
Definition: abstract_mutex.h:28
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: log_record_test_helper.h:39
AbstractMutex * mutex()
Definition: log_record.h:181
Matcher< ImageRewriteInfo > LogImageRewriteActivityMatcher(Matcher< const char * > id, Matcher< const GoogleString & > url, Matcher< RewriterApplication::Status > status, Matcher< bool > is_image_inlined, Matcher< bool > is_critical_image, Matcher< bool > is_url_rewritten, Matcher< int > size, Matcher< bool > try_low_res_src_insertion, Matcher< bool > low_res_src_inserted, Matcher< ImageType > low_res_image_type, Matcher< int > low_res_data_size)
A class which helps mock the methods of LogRecord for testing.
Definition: log_record_test_helper.h:88