Page Speed Optimization Libraries  1.7.30.2
net/instaweb/http/public/log_record_test_helper.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 Google Inc.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http:///www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00018 
00019 #ifndef NET_INSTAWEB_HTTP_PUBLIC_LOG_RECORD_TEST_HELPER_H_
00020 #define NET_INSTAWEB_HTTP_PUBLIC_LOG_RECORD_TEST_HELPER_H_
00021 
00022 #include "net/instaweb/http/public/logging_proto.h"
00023 #include "net/instaweb/http/public/log_record.h"
00024 #include "net/instaweb/rewriter/image_types.pb.h"
00025 #include "net/instaweb/util/enums.pb.h"
00026 #include "net/instaweb/util/public/gmock.h"
00027 #include "net/instaweb/util/public/string.h"
00028 
00029 using ::testing::_;
00030 using ::testing::Matcher;
00031 using ::testing::StrEq;
00032 
00033 namespace net_instaweb {
00034 
00035 class AbstractMutex;
00036 
00039 struct ImageRewriteInfo {
00040   ImageRewriteInfo(
00041       const char* id,
00042       const GoogleString& url,
00043       RewriterApplication::Status status,
00044       bool is_image_inlined,
00045       bool is_critical_image,
00046       bool is_url_rewritten,
00047       int size,
00048       bool try_low_res_src_insertion,
00049       bool low_res_src_inserted,
00050       ImageType low_res_image_type,
00051       int low_res_data_size) :
00052     id_(id), url_(url), status_(status), is_image_inlined_(is_image_inlined),
00053     is_critical_image_(is_critical_image), is_url_rewritten_(is_url_rewritten),
00054     size_(size), try_low_res_src_insertion_(try_low_res_src_insertion),
00055     low_res_src_inserted_(low_res_src_inserted),
00056     low_res_image_type_(low_res_image_type),
00057     low_res_data_size_(low_res_data_size) {}
00058 
00059   const char* id_;
00060   GoogleString url_;
00061   RewriterApplication::Status status_;
00062   bool is_image_inlined_;
00063   bool is_critical_image_;
00064   bool is_url_rewritten_;
00065   int size_;
00066   bool try_low_res_src_insertion_;
00067   bool low_res_src_inserted_;
00068   ImageType low_res_image_type_;
00069   int low_res_data_size_;
00070 };
00071 
00074 Matcher<ImageRewriteInfo> LogImageRewriteActivityMatcher(
00075     Matcher<const char*> id,
00076     Matcher<const GoogleString&> url,
00077     Matcher<RewriterApplication::Status> status,
00078     Matcher<bool> is_image_inlined,
00079     Matcher<bool> is_critical_image,
00080     Matcher<bool> is_url_rewritten,
00081     Matcher<int> size,
00082     Matcher<bool> try_low_res_src_insertion,
00083     Matcher<bool> low_res_src_inserted,
00084     Matcher<ImageType> low_res_image_type,
00085     Matcher<int> low_res_data_size);
00086 
00088 class MockLogRecord : public LogRecord {
00089  public:
00090   explicit MockLogRecord(AbstractMutex* mutex) : LogRecord(mutex) {}
00091   ~MockLogRecord() {}
00092   virtual void LogImageRewriteActivity(
00093       const char* id,
00094       const GoogleString& url,
00095       RewriterApplication::Status status,
00096       bool is_image_inlined,
00097       bool is_critical_image,
00098       bool is_url_rewritten,
00099       int size,
00100       bool try_low_res_src_insertion,
00101       bool low_res_src_inserted,
00102       ImageType low_res_image_type,
00103       int low_res_data_size) {
00104     ImageRewriteInfo info(id, url, status, is_image_inlined, is_critical_image,
00105                           is_url_rewritten, size, try_low_res_src_insertion,
00106                           low_res_src_inserted, low_res_image_type,
00107                           low_res_data_size);
00108     MockLogImageRewriteActivity(info);
00109   }
00110   MOCK_METHOD1(MockLogImageRewriteActivity, void(ImageRewriteInfo));
00111 };
00112 
00113 }  
00114 
00115 #endif  ///< NET_INSTAWEB_HTTP_PUBLIC_LOG_RECORD_TEST_HELPER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines