Page Speed Optimization Libraries  1.8.31.2
net/instaweb/spriter/mock_image_library_interface.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 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_SPRITER_MOCK_IMAGE_LIBRARY_INTERFACE_H_
00020 #define NET_INSTAWEB_SPRITER_MOCK_IMAGE_LIBRARY_INTERFACE_H_
00021 
00022 #include "net/instaweb/util/public/basictypes.h"
00023 #include "net/instaweb/util/public/gmock.h"
00024 #include "net/instaweb/util/public/gtest.h"
00025 #include "net/instaweb/util/public/string.h"
00026 #include "net/instaweb/spriter/image_library_interface.h"
00027 
00028 
00029 namespace net_instaweb {
00030 namespace spriter {
00031 
00032 class MockImageLibraryInterface : public ImageLibraryInterface {
00033  public:
00034   class MockImage : public ImageLibraryInterface::Image {
00035    public:
00036     MockImage() : Image(NULL) {}
00037     MOCK_CONST_METHOD2(GetDimensions, bool(int* out_width, int* out_height));
00038     virtual ~MockImage() {}
00039    private:
00040     explicit MockImage(MockImageLibraryInterface* lib) : Image(lib) {}
00041   };
00042 
00043   MockImageLibraryInterface(const FilePath& base_input_path,
00044                             const FilePath& base_output_path,
00045                             Delegate* delegate)
00046       : ImageLibraryInterface(base_input_path, base_output_path, delegate) {
00047   }
00048 
00051   MOCK_METHOD1(ReadFromFile, Image* (const FilePath& path));
00052 
00056   class MockCanvas : public ImageLibraryInterface::Canvas {
00057    public:
00058     MockCanvas() : Canvas(NULL) {}
00059     virtual ~MockCanvas() {}
00060     MOCK_METHOD3(DrawImage, bool(const Image* image, int x, int y));
00061     MOCK_METHOD2(WriteToFile, bool(const FilePath& write_path,
00062                                    ImageFormat format));
00063   };
00064 
00065   MOCK_METHOD2(CreateCanvas, Canvas* (int width, int height));
00066 
00067   virtual ~MockImageLibraryInterface() {}
00068 };
00069 
00070 }  
00071 }  
00072 
00073 #endif  ///< NET_INSTAWEB_SPRITER_MOCK_IMAGE_LIBRARY_INTERFACE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines