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 com.android.documentsui.base.DocumentStack;
20 import com.android.documentsui.queries.CommandInterceptor;
21 import com.android.documentsui.queries.SearchViewManager;
22 
23 /**
24  * Test copy of {@link com.android.documentsui.queries.SearchViewManager}
25  *
26  * Specficially used to test whether {@link #showMenu(boolean)}
27  * and {@link #updateMenu()} are called.
28  */
29 public class TestSearchViewManager extends SearchViewManager {
30 
31     public boolean isSearching;
32 
33     private boolean mUpdateMenuCalled;
34     private boolean mShowMenuCalled;
35 
TestSearchViewManager()36     public TestSearchViewManager() {
37         super(
38                 new SearchManagerListener() {
39                     @Override
40                     public void onSearchChanged(String query) { }
41                     @Override
42                     public void onSearchFinished() { }
43                     @Override
44                     public void onSearchViewChanged(boolean opened) { }
45                 },
46                 new CommandInterceptor(new TestFeatures()),
47                 null);
48     }
49 
50     @Override
isSearching()51     public boolean isSearching() {
52         return isSearching;
53     }
54 
55     @Override
showMenu(DocumentStack stack)56     public void showMenu(DocumentStack stack) {
57         mShowMenuCalled = true;
58     }
59 
60     @Override
updateMenu()61     public void updateMenu() {
62         mUpdateMenuCalled = true;
63     }
64 
showMenuCalled()65     public boolean showMenuCalled() {
66         return mShowMenuCalled;
67     }
68 
updateMenuCalled()69     public boolean updateMenuCalled() {
70         return mUpdateMenuCalled;
71     }
72 }
73