DetailsDialog extends BaseDialogFragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.details_dialog, container, false); extractBundle(getArguments()); ButterKnife.bind(this, rootView); name.setText(project.getName()); time.setText(project.getLastBuildTime()); url.setText(project.getWebUrl()); label.setText(project.getLastBuildLabel()); activity.setText(project.getActivity()); open.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.openUrl(project.getWebUrl(), v.getContext()); } }); return rootView; }  static DetailsDialog newInstance(Project project); @Nullable @Override View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState); static final String KEY_TAG; }
@Test public void onCreateView_SetFieldsCorrectly() throws Exception { View rootView = dialog.onCreateView(LayoutInflater.from(RuntimeEnvironment.application), null, null); assertThat(rootView).isVisible(); assertThat(dialog.name).hasText(ProjectTest.NAME); assertThat(dialog.activity).hasText(ProjectTest.ACTIVITY); assertThat(dialog.label).hasText(ProjectTest.LABEL); assertThat(dialog.time).hasText(ProjectTest.TIME); assertThat(dialog.url).hasText(ProjectTest.WEB_URL); }
@Test public void onCreateView_OpenClicked_StartsWebBrowser() throws Exception { dialog.onCreateView(LayoutInflater.from(RuntimeEnvironment.application), null, null); dialog.open.performClick(); Intent next = ShadowApplication.getInstance().getNextStartedActivity(); assertThat(next).hasAction(Intent.ACTION_VIEW).hasData(ProjectTest.WEB_URL); }