1/* 2 * Copyright (C) 2011 The Android Open Source Project 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.android.volley.mock; 18 19import com.android.volley.Request; 20import com.android.volley.Response; 21import com.android.volley.ResponseDelivery; 22import com.android.volley.VolleyError; 23 24public class MockResponseDelivery implements ResponseDelivery { 25 26 public boolean postResponse_called = false; 27 public boolean postError_called = false; 28 29 public boolean wasEitherResponseCalled() { 30 return postResponse_called || postError_called; 31 } 32 33 public Response<?> responsePosted = null; 34 @Override 35 public void postResponse(Request<?> request, Response<?> response) { 36 postResponse_called = true; 37 responsePosted = response; 38 } 39 40 @Override 41 public void postResponse(Request<?> request, Response<?> response, Runnable runnable) { 42 postResponse_called = true; 43 responsePosted = response; 44 runnable.run(); 45 } 46 47 @Override 48 public void postError(Request<?> request, VolleyError error) { 49 postError_called = true; 50 } 51 52 @Override 53 public void discardBefore(int sequence) { 54 } 55 56} 57