public void testHotWaterTemperature() throws Exception { // check if the hot tap sets the right temperature boolean expected = true; imageView2.setPressed(true); TextView tv = (TextView) mainActivity.findViewById(R.id.textView1); String data = tv.getText().toString(); boolean actual = data.contains("50.0"); assertEquals(expected, actual); }
// test to check if the image view'state is same across screen rotation public void testHotWaterTapImageStateOnScreenOrientationChanged() { float angle_before = 0; float angle_after = 0; imageView1.setPressed(true); angle_before = imageView1.getRotation(); mainActivity.finish(); mainActivity = getActivity(); if (imageView1 != null) { angle_after = imageView1.getRotation(); } assertEquals("HOtTap ImageView is restored after rotation", angle_before, angle_after); }
@Override public void setUp() throws Exception { // setUp() is run before a test case is started. super.setUp(); mainActivity = getActivity(); bathView = new BathView(mainActivity.getApplicationContext()); netUtil = new NetworkUtility(mainActivity.getApplicationContext()); imageView1 = (ImageView) mainActivity.findViewById(R.id.coldButton); imageView2 = (ImageView) mainActivity.findViewById(R.id.hotButton); textView1 = (TextView) mainActivity.findViewById(R.id.hotButtonText); textView2 = (TextView) mainActivity.findViewById(R.id.coldButtonText); }