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.Intent;
     20 
     21 import com.android.documentsui.AbstractActionHandler;
     22 import com.android.documentsui.ActionHandler;
     23 import com.android.documentsui.TestActivity;
     24 import com.android.documentsui.base.RootInfo;
     25 import com.android.documentsui.dirlist.DocumentDetails;
     26 import com.android.documentsui.Model;
     27 
     28 public class TestActionHandler extends AbstractActionHandler<TestActivity> {
     29 
     30     public final TestEventHandler<DocumentDetails> open = new TestEventHandler<>();
     31     public boolean mDeleteHappened;
     32 
     33     public TestActionHandler() {
     34         this(TestEnv.create());
     35     }
     36 
     37     public TestActionHandler(TestEnv env) {
     38         super(
     39                 TestActivity.create(env),
     40                 env.state,
     41                 env.roots,
     42                 env.docs,
     43                 env.searchViewManager,
     44                 (String authority) -> null,
     45                 env.injector);
     46     }
     47 
     48     @Override
     49     public boolean openDocument(DocumentDetails doc, @ViewType int type, @ViewType int fallback) {
     50         return open.accept(doc);
     51     }
     52 
     53     @Override
     54     public void deleteSelectedDocuments() {
     55         mDeleteHappened = true;
     56     }
     57 
     58     @Override
     59     public void openRoot(RootInfo root) {
     60         throw new UnsupportedOperationException();
     61     }
     62 
     63     @Override
     64     public void initLocation(Intent intent) {
     65         throw new UnsupportedOperationException();
     66     }
     67 
     68     @Override
     69     protected void launchToDefaultLocation() {
     70         throw new UnsupportedOperationException();
     71     }
     72 }
     73