plectrum

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit ab2b8d8b47613881b30bd4871f4cfdc82fd272fe
parent be0dad5ef3c48b1e98def6e3111da3cbfe1ac556
Author: gstraube <gstraube@mailbox.org>
Date:   Sat, 12 Aug 2017 16:14:38 +0200

Extract method

Diffstat:
Mapp/src/androidTest/java/com/github/cythara/TunerViewTest.java | 29+++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/app/src/androidTest/java/com/github/cythara/TunerViewTest.java b/app/src/androidTest/java/com/github/cythara/TunerViewTest.java @@ -38,39 +38,28 @@ public class TunerViewTest { @Test public void exactly_matching_pitch_is_displayed() throws IOException { - MainActivity mainActivity = mActivityRule.getActivity(); - - BitmapFactory.Options options = new BitmapFactory.Options(); - options.inScaled = false; - Bitmap reference = BitmapFactory.decodeResource(mainActivity.getResources(), - R.drawable.exact, options); - - Bitmap generated = Bitmap.createBitmap(2048, 1024, Bitmap.Config.ARGB_4444); - Canvas canvas = new Canvas(generated); - TunerView tunerView = (TunerView) mainActivity.findViewById(R.id.pitch); - tunerView.setPitchDifference(new PitchDifference(Note.E4, 0)); - - tunerView.draw(canvas); - - Assert.assertTrue(reference.sameAs(generated)); - - writeToFile(generated, "generated.png"); - writeToFile(reference, "reference.png"); + isDisplayedCorrectly(R.drawable.exact, new PitchDifference(Note.E4, 0)); } @Test public void positive_10_cents_deviation_is_displayed() throws IOException { + isDisplayedCorrectly(R.drawable.positive_10_cents, + new PitchDifference(Note.B3, 10)); + } + + public void isDisplayedCorrectly(int referenceId, PitchDifference pitchDifference) + throws IOException { MainActivity mainActivity = mActivityRule.getActivity(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inScaled = false; Bitmap reference = BitmapFactory.decodeResource(mainActivity.getResources(), - R.drawable.positive_10_cents, options); + referenceId, options); Bitmap generated = Bitmap.createBitmap(2048, 1024, Bitmap.Config.ARGB_4444); Canvas canvas = new Canvas(generated); TunerView tunerView = (TunerView) mainActivity.findViewById(R.id.pitch); - tunerView.setPitchDifference(new PitchDifference(Note.B3, 10)); + tunerView.setPitchDifference(pitchDifference); tunerView.draw(canvas);