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 android.content.ClipData;
     20 import android.view.DragEvent;
     21 
     22 import org.mockito.Mockito;
     23 
     24 public final class DragEvents {
     25 
     26     private DragEvents() {}
     27 
     28     public static DragEvent createTestDragEvent(int actionId) {
     29         final DragEvent mockEvent = Mockito.mock(DragEvent.class);
     30         Mockito.when(mockEvent.getAction()).thenReturn(actionId);
     31 
     32         return mockEvent;
     33     }
     34 
     35     public static DragEvent createTestLocationEvent(float x, float y) {
     36         final DragEvent locationEvent = createTestDragEvent(DragEvent.ACTION_DRAG_LOCATION);
     37         Mockito.when(locationEvent.getX()).thenReturn(x);
     38         Mockito.when(locationEvent.getY()).thenReturn(y);
     39 
     40         return locationEvent;
     41     }
     42 
     43     public static DragEvent createTestDropEvent(ClipData clipData) {
     44         final DragEvent dropEvent = createTestDragEvent(DragEvent.ACTION_DROP);
     45         Mockito.when(dropEvent.getClipData()).thenReturn(clipData);
     46 
     47         return dropEvent;
     48     }
     49 
     50 }
     51