1 /* 2 * Copyright (C) 2016 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 17 package com.android.documentsui.services; 18 19 import static junit.framework.Assert.assertTrue; 20 21 import android.app.Notification; 22 import android.app.Notification.Builder; 23 import android.content.Context; 24 25 import com.android.documentsui.R; 26 import com.android.documentsui.model.DocumentInfo; 27 import com.android.documentsui.model.DocumentStack; 28 29 public class TestJob extends Job { 30 31 private boolean mStarted; 32 33 TestJob( 34 Context service, Context appContext, Listener listener, 35 int operationType, String id, DocumentStack stack) { 36 super(service, appContext, listener, operationType, id, stack); 37 } 38 39 @Override 40 void start() { 41 mStarted = true; 42 } 43 44 void assertStarted() { 45 assertTrue(mStarted); 46 } 47 48 void fail(DocumentInfo doc) { 49 onFileFailed(doc); 50 } 51 52 @Override 53 Notification getSetupNotification() { 54 return getSetupNotification(service.getString(R.string.copy_preparing)); 55 } 56 57 @Override 58 Notification getFailureNotification() { 59 // the "copy" stuff was just convenient and available :) 60 return getFailureNotification( 61 R.plurals.copy_error_notification_title, R.drawable.ic_menu_copy); 62 } 63 64 @Override 65 Notification getWarningNotification() { 66 throw new UnsupportedOperationException(); 67 } 68 69 @Override 70 Builder createProgressBuilder() { 71 // the "copy" stuff was just convenient and available :) 72 return super.createProgressBuilder( 73 service.getString(R.string.copy_notification_title), 74 R.drawable.ic_menu_copy, 75 service.getString(android.R.string.cancel), 76 R.drawable.ic_cab_cancel); 77 } 78 } 79