1/* 2 * Copyright 2012 AndroidPlot.com 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 17package com.androidplot.mock; 18 19import android.graphics.RectF; 20import mockit.Instantiation; 21import mockit.Mock; 22import mockit.MockClass; 23 24@MockClass(realClass = RectF.class, stubs="", inverse=true) 25public final class MockRectF { 26 //public float left; 27 //public float top; 28 //public float right; 29 //public float bottom; 30 31 public RectF it; 32 33 @Mock 34 public void $init() { 35 36 } 37 38 @Mock 39 public void $init(RectF rhs) { 40 it.left = rhs.left; 41 it.top = rhs.top; 42 it.right = rhs.right; 43 it.bottom = rhs.bottom; 44 } 45 46 @Mock 47 public void $init(float left, float top, float right, float bottom) { 48 it.left = left; 49 it.top = top; 50 it.right = right; 51 it.bottom = bottom; 52 // do anything here 53 54 } 55 56 @Mock 57 public void offset(float dx, float dy) { 58 float w = width(); 59 float h = height(); 60 61 it.left = it.left + dx; 62 it.right = it.right + dx; 63 64 it.top = it.top + dy; 65 it.bottom = it.bottom + dy; 66 } 67 68 @Mock 69 public void offsetTo(float left, float top) { 70 71 it.right = left + width(); 72 it.bottom = top + height(); 73 74 it.left = left; 75 it.top = top; 76 77 // do anything here 78 } 79 80 @Mock 81 public float height() { 82 return it.bottom - it.top; 83 } 84 85 @Mock 86 public float width() { 87 return it.right - it.left; 88 } 89 90 @Mock 91 public String toString() { 92 return null; 93 } 94} 95