NavigationBarFragmentTest.java revision 865246dc9ac488a440f8ca13973dbd8c60fede1e
1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15package com.android.systemui.statusbar.phone; 16 17import static org.mockito.Mockito.mock; 18 19import android.content.Context; 20import android.view.WindowManager; 21 22import com.android.systemui.FragmentTestCase; 23import com.android.systemui.assist.AssistManager; 24import com.android.systemui.recents.Recents; 25import com.android.systemui.stackdivider.Divider; 26import com.android.systemui.statusbar.CommandQueue; 27 28import org.junit.Before; 29import org.junit.Test; 30 31public class NavigationBarFragmentTest extends FragmentTestCase { 32 33 public NavigationBarFragmentTest() { 34 super(NavigationBarFragment.class); 35 } 36 37 @Before 38 public void setup() { 39 mContext.putComponent(CommandQueue.class, mock(CommandQueue.class)); 40 mContext.putComponent(PhoneStatusBar.class, mock(PhoneStatusBar.class)); 41 mContext.putComponent(Recents.class, mock(Recents.class)); 42 mContext.putComponent(Divider.class, mock(Divider.class)); 43 } 44 45 @Test 46 public void testHomeLongPress() { 47 mContext.addMockSystemService(Context.WINDOW_SERVICE, mock(WindowManager.class)); 48 NavigationBarFragment navigationBarFragment = (NavigationBarFragment) mFragment; 49 50 AssistManager assistManager = new AssistManager(mContext.getComponent(PhoneStatusBar.class), 51 mContext); 52 navigationBarFragment.setAssistManager(assistManager); 53 54 postAndWait(() -> mFragments.dispatchResume()); 55 navigationBarFragment.onHomeLongClick(navigationBarFragment.getView()); 56 } 57 58} 59