aboutsummaryrefslogtreecommitdiff
path: root/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java')
-rw-r--r--tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java69
1 files changed, 29 insertions, 40 deletions
diff --git a/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java b/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java
index a793ac71..c9153d1c 100644
--- a/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java
+++ b/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java
@@ -22,24 +22,17 @@ import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
-import android.media.tv.TvContract;
import android.media.tv.TvInputInfo;
import android.os.Bundle;
import android.util.Log;
-
-import com.android.tv.testing.ChannelInfo;
-import com.android.tv.testing.ChannelUtils;
-import com.android.tv.testing.Constants;
-import com.android.tv.testing.ProgramInfo;
-import com.android.tv.testing.ProgramUtils;
-
-import java.util.ArrayList;
+import com.android.tv.common.util.Clock;
+import com.android.tv.testing.constants.Constants;
+import com.android.tv.testing.data.ChannelInfo;
+import com.android.tv.testing.data.ChannelUtils;
+import com.android.tv.testing.data.ProgramUtils;
import java.util.List;
-import java.util.Map;
-/**
- * The setup activity for {@link TestTvInputService}.
- */
+/** The setup activity for {@link TestTvInputService}. */
public class TestTvInputSetupActivity extends Activity {
private static final String TAG = "TestTvInputSetup";
private String mInputId;
@@ -60,45 +53,41 @@ public class TestTvInputSetupActivity extends Activity {
public static void registerChannels(Context context, String inputId, int channelCount) {
Log.i(TAG, "Registering " + channelCount + " channels");
- List<ChannelInfo> channels = new ArrayList<>();
- for (int i = 1; i <= channelCount; i++) {
- channels.add(ChannelInfo.create(context, i));
- }
+ List<ChannelInfo> channels = ChannelUtils.createChannelInfos(context, channelCount);
ChannelUtils.updateChannels(context, inputId, channels);
-
- // Reload channels so we have the ids.
- Map<Long, ChannelInfo> channelIdToInfoMap =
- ChannelUtils.queryChannelInfoMapForTvInput(context, inputId);
- for (Long channelId : channelIdToInfoMap.keySet()) {
- ProgramInfo programInfo = ProgramInfo.create();
- ProgramUtils.populatePrograms(context, TvContract.buildChannelUri(channelId),
- programInfo);
- }
+ ProgramUtils.updateProgramForAllChannelsOf(
+ context, inputId, Clock.SYSTEM, ProgramUtils.PROGRAM_INSERT_DURATION_MS);
}
public static class MyAlertDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
- return new AlertDialog.Builder(getActivity()).setTitle(R.string.simple_setup_title)
+ return new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.simple_setup_title)
.setMessage(R.string.simple_setup_message)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- // TODO: add UI to ask how many channels
- ((TestTvInputSetupActivity) getActivity())
- .registerChannels(Constants.UNIT_TEST_CHANNEL_COUNT);
- // Sets the results so that the application can process the
- // registered channels properly.
- getActivity().setResult(Activity.RESULT_OK);
- getActivity().finish();
- }
- }).setNegativeButton(android.R.string.cancel,
+ .setPositiveButton(
+ android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int whichButton) {
+ // TODO: add UI to ask how many channels
+ ((TestTvInputSetupActivity) getActivity())
+ .registerChannels(Constants.UNIT_TEST_CHANNEL_COUNT);
+ // Sets the results so that the application can process the
+ // registered channels properly.
+ getActivity().setResult(Activity.RESULT_OK);
+ getActivity().finish();
+ }
+ })
+ .setNegativeButton(
+ android.R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
getActivity().finish();
}
- }).create();
+ })
+ .create();
}
}
}