Home | History | Annotate | Download | only in testing
      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.testing;
     18 
     19 import static junit.framework.Assert.assertNull;
     20 import static junit.framework.Assert.assertSame;
     21 
     22 import android.content.ClipData;
     23 import android.net.Uri;
     24 
     25 import com.android.documentsui.base.DocumentInfo;
     26 import com.android.documentsui.base.DocumentStack;
     27 import com.android.documentsui.base.RootInfo;
     28 import com.android.documentsui.clipping.DocumentClipper;
     29 import com.android.documentsui.selection.Selection;
     30 import com.android.documentsui.services.FileOperations.Callback;
     31 
     32 import java.util.function.Function;
     33 
     34 public class TestDocumentClipper implements DocumentClipper {
     35 
     36     private ClipData mLastClipData;
     37 
     38     @Override
     39     public boolean hasItemsToPaste() {
     40         return false;
     41     }
     42 
     43     @Override
     44     public ClipData getClipDataForDocuments(Function<String, Uri> uriBuilder, Selection selection,
     45             int opType) {
     46         return null;
     47     }
     48 
     49     @Override
     50     public void clipDocumentsForCopy(Function<String, Uri> uriBuilder, Selection selection) {
     51 
     52     }
     53 
     54     @Override
     55     public void clipDocumentsForCut(Function<String, Uri> uriBuilder, Selection selection,
     56             DocumentInfo parent) {
     57     }
     58 
     59     @Override
     60     public void copyFromClipboard(DocumentInfo destination, DocumentStack docStack,
     61             Callback callback) {
     62     }
     63 
     64     @Override
     65     public void copyFromClipboard(DocumentStack docStack, Callback callback) {
     66     }
     67 
     68     @Override
     69     public void copyFromClipData(RootInfo root, DocumentInfo destination, ClipData clipData,
     70             Callback callback) {
     71         mLastClipData = clipData;
     72     }
     73 
     74     @Override
     75     public void copyFromClipData(DocumentInfo destination, DocumentStack docStack,
     76             ClipData clipData, Callback callback) {
     77     }
     78 
     79     @Override
     80     public void copyFromClipData(DocumentStack docStack, ClipData clipData, Callback callback) {
     81     }
     82 
     83     @Override
     84     public int getOpType(ClipData data) {
     85         return 0;
     86     }
     87 
     88     public void assertNoClipData() {
     89         assertNull(mLastClipData);
     90     }
     91 
     92     public void assertSameClipData(ClipData expect) {
     93         assertSame(expect, mLastClipData);
     94     }
     95 }
     96