1 /* 2 * Copyright (C) 2017 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.tv.util; 18 19 import android.content.Context; 20 21 import com.android.tv.ApplicationSingletons; 22 import com.android.tv.InputSessionManager; 23 import com.android.tv.MainActivityWrapper; 24 import com.android.tv.TvApplication; 25 import com.android.tv.analytics.Analytics; 26 import com.android.tv.analytics.Tracker; 27 import com.android.tv.config.RemoteConfig; 28 import com.android.tv.data.ChannelDataManager; 29 import com.android.tv.data.PreviewDataManager; 30 import com.android.tv.data.ProgramDataManager; 31 import com.android.tv.dvr.DvrDataManager; 32 import com.android.tv.dvr.DvrManager; 33 import com.android.tv.dvr.DvrScheduleManager; 34 import com.android.tv.dvr.DvrStorageStatusManager; 35 import com.android.tv.dvr.DvrWatchedPositionManager; 36 import com.android.tv.dvr.recorder.RecordingScheduler; 37 import com.android.tv.perf.PerformanceMonitor; 38 39 /** 40 * Mock {@link ApplicationSingletons} class. 41 */ 42 public class MockApplicationSingletons implements ApplicationSingletons { 43 private final TvApplication mApp; 44 45 private PerformanceMonitor mPerformanceMonitor; 46 47 public MockApplicationSingletons(Context context) { 48 mApp = (TvApplication) context.getApplicationContext(); 49 } 50 51 @Override 52 public Analytics getAnalytics() { 53 return mApp.getAnalytics(); 54 } 55 56 @Override 57 public ChannelDataManager getChannelDataManager() { 58 return mApp.getChannelDataManager(); 59 } 60 61 @Override 62 public boolean isChannelDataManagerLoadFinished() { 63 return mApp.isChannelDataManagerLoadFinished(); 64 } 65 66 @Override 67 public ProgramDataManager getProgramDataManager() { 68 return mApp.getProgramDataManager(); 69 } 70 71 @Override 72 public boolean isProgramDataManagerCurrentProgramsLoadFinished() { 73 return mApp.isProgramDataManagerCurrentProgramsLoadFinished(); 74 } 75 76 @Override 77 public PreviewDataManager getPreviewDataManager() { 78 return mApp.getPreviewDataManager(); 79 } 80 81 @Override 82 public DvrDataManager getDvrDataManager() { 83 return mApp.getDvrDataManager(); 84 } 85 86 @Override 87 public DvrStorageStatusManager getDvrStorageStatusManager() { 88 return mApp.getDvrStorageStatusManager(); 89 } 90 91 @Override 92 public DvrScheduleManager getDvrScheduleManager() { 93 return mApp.getDvrScheduleManager(); 94 } 95 96 @Override 97 public DvrManager getDvrManager() { 98 return mApp.getDvrManager(); 99 } 100 101 @Override 102 public RecordingScheduler getRecordingScheduler() { 103 return mApp.getRecordingScheduler(); 104 } 105 106 @Override 107 public DvrWatchedPositionManager getDvrWatchedPositionManager() { 108 return mApp.getDvrWatchedPositionManager(); 109 } 110 111 @Override 112 public InputSessionManager getInputSessionManager() { 113 return mApp.getInputSessionManager(); 114 } 115 116 @Override 117 public Tracker getTracker() { 118 return mApp.getTracker(); 119 } 120 121 @Override 122 public TvInputManagerHelper getTvInputManagerHelper() { 123 return mApp.getTvInputManagerHelper(); 124 } 125 126 @Override 127 public MainActivityWrapper getMainActivityWrapper() { 128 return mApp.getMainActivityWrapper(); 129 } 130 131 @Override 132 public AccountHelper getAccountHelper() { 133 return mApp.getAccountHelper(); 134 } 135 136 @Override 137 public RemoteConfig getRemoteConfig() { 138 return mApp.getRemoteConfig(); 139 } 140 141 @Override 142 public boolean isRunningInMainProcess() { 143 return mApp.isRunningInMainProcess(); 144 } 145 146 @Override 147 public PerformanceMonitor getPerformanceMonitor() { 148 return mPerformanceMonitor != null ? mPerformanceMonitor : mApp.getPerformanceMonitor(); 149 } 150 151 public void setPerformanceMonitor(PerformanceMonitor performanceMonitor) { 152 mPerformanceMonitor = performanceMonitor; 153 } 154 } 155