Page Speed Optimization Libraries
1.8.31.2
|
00001 00002 /* 00003 * Copyright 2010 Google Inc. 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http:///www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00018 00020 00021 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_IMAGE_TEST_BASE_H_ 00022 #define NET_INSTAWEB_REWRITER_PUBLIC_IMAGE_TEST_BASE_H_ 00023 00024 #include "net/instaweb/rewriter/public/image.h" 00025 00026 #include "net/instaweb/rewriter/image_types.pb.h" 00027 #include "net/instaweb/util/public/basictypes.h" 00028 #include "net/instaweb/util/public/gtest.h" 00029 #include "net/instaweb/util/public/mock_message_handler.h" 00030 #include "net/instaweb/util/public/mock_timer.h" 00031 #include "net/instaweb/util/public/null_mutex.h" 00032 #include "net/instaweb/util/public/scoped_ptr.h" 00033 #include "net/instaweb/util/public/stdio_file_system.h" 00034 #include "net/instaweb/util/public/string.h" 00035 00036 namespace net_instaweb { 00037 00038 class ImageTestBase : public testing::Test { 00039 protected: 00040 static const char kTestData[]; 00041 static const char kAppSegments[]; 00042 static const char kBikeCrash[]; 00043 static const char kCradle[]; 00044 static const char kCuppa[]; 00045 static const char kCuppaTransparent[]; 00046 static const char kIronChef[]; 00047 static const char kLarge[]; 00048 static const char kPuzzle[]; 00049 static const char kRedbrush[]; 00050 static const char kScenery[]; 00051 static const char kTransparent[]; 00052 00053 typedef scoped_ptr<Image> ImagePtr; 00054 00055 ImageTestBase() : 00056 timer_(new NullMutex, 0), 00057 message_handler_(new NullMutex) { 00058 } 00059 00060 virtual ~ImageTestBase(); 00061 00064 Image* ImageFromString(ImageType output_type, 00065 const GoogleString& name, 00066 const GoogleString& contents, 00067 bool progressive); 00068 00071 Image* ReadFromFileWithOptions( 00072 const char* name, GoogleString* contents, 00073 Image::CompressionOptions* options); 00074 00077 Image* ReadImageFromFile(ImageType output_type, 00078 const char* filename, GoogleString* buffer, 00079 bool progressive); 00080 00081 MockTimer timer_; 00082 StdioFileSystem file_system_; 00083 MockMessageHandler message_handler_; 00084 00085 private: 00086 DISALLOW_COPY_AND_ASSIGN(ImageTestBase); 00087 }; 00088 00089 } 00090 00091 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_IMAGE_TEST_BASE_H_