Search in sources :

Example 31 with LoadingViewController

use of com.android.settings.widget.LoadingViewController in project android_packages_apps_Settings by crdroidandroid.

the class ManageApplicationsTest method updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer.

@Test
public void updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer() {
    final ManageApplications fragment = mock(ManageApplications.class);
    ReflectionHelpers.setField(fragment, "mLoadingContainer", mock(View.class));
    ReflectionHelpers.setField(fragment, "mListContainer", mock(View.class));
    when(fragment.getActivity()).thenReturn(mock(Activity.class));
    final Handler handler = mock(Handler.class);
    final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, fragment, 0));
    final LoadingViewController loadingViewController = mock(LoadingViewController.class);
    ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
    ReflectionHelpers.setField(adapter, "mFgHandler", handler);
    // app loading completed
    ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", true);
    final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
    appList.add(mock(ApplicationsState.AppEntry.class));
    when(mSession.getAllApps()).thenReturn(appList);
    adapter.updateLoading();
    verify(loadingViewController, never()).showLoadingViewDelayed();
}
Also used : ArrayList(java.util.ArrayList) Activity(android.app.Activity) Handler(android.os.Handler) LoadingViewController(com.android.settings.widget.LoadingViewController) View(android.view.View) TextView(android.widget.TextView) Test(org.junit.Test)

Example 32 with LoadingViewController

use of com.android.settings.widget.LoadingViewController in project android_packages_apps_Settings by SudaMod.

the class ManageApplicationsTest method onRebuildComplete_shouldHideLoadingView.

@Test
public void onRebuildComplete_shouldHideLoadingView() {
    final Context context = RuntimeEnvironment.application;
    final ManageApplications fragment = mock(ManageApplications.class);
    final View loadingContainer = mock(View.class);
    when(loadingContainer.getContext()).thenReturn(context);
    final View listContainer = mock(View.class);
    when(listContainer.getVisibility()).thenReturn(View.INVISIBLE);
    when(listContainer.getContext()).thenReturn(context);
    ReflectionHelpers.setField(fragment, "mLoadingContainer", loadingContainer);
    ReflectionHelpers.setField(fragment, "mListContainer", listContainer);
    when(fragment.getActivity()).thenReturn(mock(Activity.class));
    final Handler handler = mock(Handler.class);
    final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, fragment, 0));
    final LoadingViewController loadingViewController = mock(LoadingViewController.class);
    ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
    ReflectionHelpers.setField(adapter, "mFgHandler", handler);
    ReflectionHelpers.setField(adapter, "mFilterMode", -1);
    // app loading not yet completed
    ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", false);
    adapter.updateLoading();
    // app loading completed
    ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", true);
    final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
    appList.add(mock(ApplicationsState.AppEntry.class));
    when(mSession.getAllApps()).thenReturn(appList);
    adapter.onRebuildComplete(null);
    verify(loadingViewController).showContent(true);
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) Activity(android.app.Activity) Handler(android.os.Handler) LoadingViewController(com.android.settings.widget.LoadingViewController) View(android.view.View) TextView(android.widget.TextView) Test(org.junit.Test)

Example 33 with LoadingViewController

use of com.android.settings.widget.LoadingViewController in project android_packages_apps_Settings by SudaMod.

the class ManageApplicationsTest method updateLoading_appNotLoaded_shouldDelayCallToHandleLoadingContainer.

@Test
public void updateLoading_appNotLoaded_shouldDelayCallToHandleLoadingContainer() {
    final ManageApplications fragment = mock(ManageApplications.class);
    ReflectionHelpers.setField(fragment, "mLoadingContainer", mock(View.class));
    ReflectionHelpers.setField(fragment, "mListContainer", mock(View.class));
    when(fragment.getActivity()).thenReturn(mock(Activity.class));
    final Handler handler = mock(Handler.class);
    final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, fragment, 0));
    final LoadingViewController loadingViewController = mock(LoadingViewController.class);
    ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
    ReflectionHelpers.setField(adapter, "mFgHandler", handler);
    // app loading not yet completed
    ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", false);
    adapter.updateLoading();
    verify(loadingViewController).showLoadingViewDelayed();
}
Also used : Activity(android.app.Activity) Handler(android.os.Handler) LoadingViewController(com.android.settings.widget.LoadingViewController) View(android.view.View) TextView(android.widget.TextView) Test(org.junit.Test)

Example 34 with LoadingViewController

use of com.android.settings.widget.LoadingViewController in project android_packages_apps_Settings by SudaMod.

the class ManageApplicationsTest method updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer.

@Test
public void updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer() {
    final ManageApplications fragment = mock(ManageApplications.class);
    ReflectionHelpers.setField(fragment, "mLoadingContainer", mock(View.class));
    ReflectionHelpers.setField(fragment, "mListContainer", mock(View.class));
    when(fragment.getActivity()).thenReturn(mock(Activity.class));
    final Handler handler = mock(Handler.class);
    final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, fragment, 0));
    final LoadingViewController loadingViewController = mock(LoadingViewController.class);
    ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
    ReflectionHelpers.setField(adapter, "mFgHandler", handler);
    // app loading completed
    ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", true);
    final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
    appList.add(mock(ApplicationsState.AppEntry.class));
    when(mSession.getAllApps()).thenReturn(appList);
    adapter.updateLoading();
    verify(loadingViewController, never()).showLoadingViewDelayed();
}
Also used : ArrayList(java.util.ArrayList) Activity(android.app.Activity) Handler(android.os.Handler) LoadingViewController(com.android.settings.widget.LoadingViewController) View(android.view.View) TextView(android.widget.TextView) Test(org.junit.Test)

Example 35 with LoadingViewController

use of com.android.settings.widget.LoadingViewController in project platform_packages_apps_Settings by BlissRoms.

the class ManageApplicationsTest method updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer.

@Test
public void updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer() {
    final ManageApplications fragment = mock(ManageApplications.class);
    ReflectionHelpers.setField(fragment, "mLoadingContainer", mock(View.class));
    ReflectionHelpers.setField(fragment, "mListContainer", mock(View.class));
    when(fragment.getActivity()).thenReturn(mock(Activity.class));
    final Handler handler = mock(Handler.class);
    final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, fragment, 0));
    final LoadingViewController loadingViewController = mock(LoadingViewController.class);
    ReflectionHelpers.setField(adapter, "mLoadingViewController", loadingViewController);
    ReflectionHelpers.setField(adapter, "mFgHandler", handler);
    // app loading completed
    ReflectionHelpers.setField(adapter, "mHasReceivedLoadEntries", true);
    final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
    appList.add(mock(ApplicationsState.AppEntry.class));
    when(mSession.getAllApps()).thenReturn(appList);
    adapter.updateLoading();
    verify(loadingViewController, never()).showLoadingViewDelayed();
}
Also used : ArrayList(java.util.ArrayList) Activity(android.app.Activity) Handler(android.os.Handler) LoadingViewController(com.android.settings.widget.LoadingViewController) View(android.view.View) TextView(android.widget.TextView) Test(org.junit.Test)

Aggregations

LoadingViewController (com.android.settings.widget.LoadingViewController)40 View (android.view.View)32 Test (org.junit.Test)26 Activity (android.app.Activity)18 Handler (android.os.Handler)18 TextView (android.widget.TextView)18 ArrayList (java.util.ArrayList)16 Bundle (android.os.Bundle)13 Context (android.content.Context)8 OnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)7 SpinnerInterface (com.android.settings.datausage.CycleAdapter.SpinnerInterface)7 SearchView (android.widget.SearchView)6 RecyclerView (androidx.recyclerview.widget.RecyclerView)6 Spinner (android.widget.Spinner)2 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)2 AppEntry (com.android.settingslib.applications.ApplicationsState.AppEntry)2 AccessibilityDelegate (android.view.View.AccessibilityDelegate)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1