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 org.mockito.Mockito.mock; 20 21 import android.view.View; 22 import android.view.ViewGroup; 23 24 import com.android.documentsui.base.DocumentStack; 25 import com.android.documentsui.queries.CommandInterceptor; 26 import com.android.documentsui.queries.SearchViewManager; 27 28 /** 29 * Test copy of {@link com.android.documentsui.queries.SearchViewManager} 30 * 31 * Specifically used to test whether {@link #showMenu(boolean)} 32 * and {@link #updateMenu()} are called. 33 */ 34 public class TestSearchViewManager extends SearchViewManager { 35 36 public boolean isSearching; 37 38 private boolean mUpdateMenuCalled; 39 private boolean mShowMenuCalled; 40 TestSearchViewManager()41 public TestSearchViewManager() { 42 super( 43 new SearchManagerListener() { 44 @Override 45 public void onSearchChanged(String query) { 46 } 47 48 @Override 49 public void onSearchFinished() { 50 } 51 52 @Override 53 public void onSearchViewChanged(boolean opened) { 54 } 55 56 @Override 57 public void onSearchChipStateChanged(View v) { 58 } 59 60 @Override 61 public void onSearchViewFocusChanged(boolean hasFocus) { 62 } 63 64 @Override 65 public void onSearchViewClearClicked() { 66 } 67 }, 68 new CommandInterceptor(new TestFeatures()), mock(ViewGroup.class), 69 null /* savedState */); 70 } 71 72 @Override isSearching()73 public boolean isSearching() { 74 return isSearching; 75 } 76 77 @Override showMenu(DocumentStack stack)78 public void showMenu(DocumentStack stack) { 79 mShowMenuCalled = true; 80 } 81 82 @Override updateMenu()83 public void updateMenu() { 84 mUpdateMenuCalled = true; 85 } 86 showMenuCalled()87 public boolean showMenuCalled() { 88 return mShowMenuCalled; 89 } 90 updateMenuCalled()91 public boolean updateMenuCalled() { 92 return mUpdateMenuCalled; 93 } 94 } 95