Skip to content

Commit

Permalink
2019 native breakdown view (#892)
Browse files Browse the repository at this point in the history
* 2019 native breakdown view

* add unit tests

* lint

* fix test
  • Loading branch information
phil-lopreiato authored Feb 24, 2019
1 parent d8950a9 commit a6356ad
Show file tree
Hide file tree
Showing 53 changed files with 1,687 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.thebluealliance.androidclient.views.breakdowns;

import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import com.facebook.testing.screenshot.Screenshot;
import com.facebook.testing.screenshot.ViewHelpers;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.thebluealliance.androidclient.R;
import com.thebluealliance.androidclient.datafeed.HttpModule;
import com.thebluealliance.androidclient.models.Match;
import com.thebluealliance.androidclient.testing.ModelMaker;
import com.thebluealliance.androidclient.types.MatchType;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@RunWith(AndroidJUnit4.class)
public class MatchBreakdownView2019Test {
private static final int WIDTH_DP = 400;
private Gson mGson;

@Before
public void setUp() {
mGson = HttpModule.getGson();
}

@Test
public void testRenderQualMatch() throws Exception {
View view = getView("2019week0_qm6");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();

Screenshot.snap(view)
.record();
}

@Test
public void testRenderPlayoffMatch() throws Exception {
View view = getView("2019week0_f1m1");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();

Screenshot.snap(view)
.record();
}


private MatchBreakdownView2019 getView(String matchJsonFile) {
Match match = ModelMaker.getModel(Match.class, matchJsonFile);
LayoutInflater inflater = LayoutInflater.from(InstrumentationRegistry.getTargetContext());
View view = inflater.inflate(R.layout.fragment_match_breakdown, null, false);

FrameLayout matchView = view.findViewById(R.id.match_breakdown);
assertEquals(1, matchView.getChildCount());
assertTrue(matchView.getChildAt(0) instanceof MatchBreakdownView2019);
MatchBreakdownView2019 view2019 = (MatchBreakdownView2019) matchView.getChildAt(0);
MatchType matchType = MatchType.fromKey(match.getKey());
view2019.initWithData(matchType, match.getWinningAlliance(), match.getAlliances(),
mGson.fromJson(match.getScoreBreakdown(), JsonObject.class));
view2019.setVisibility(View.VISIBLE);

// hide progress bar
view.findViewById(R.id.progress).setVisibility(View.GONE);
return view2019;
}
}
148 changes: 148 additions & 0 deletions android/src/androidTest/resources/2019week0_f1m1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"actual_time": 1550349044,
"alliances": {
"blue": {
"dq_team_keys": [],
"score": 50,
"surrogate_team_keys": [],
"team_keys": [
"frc5687",
"frc58",
"frc1517"
]
},
"red": {
"dq_team_keys": [],
"score": 32,
"surrogate_team_keys": [],
"team_keys": [
"frc1153",
"frc3236",
"frc246"
]
}
},
"comp_level": "f",
"event_key": "2019week0",
"key": "2019week0_f1m1",
"match_number": 1,
"post_result_time": 1550349303,
"predicted_time": 1550349181,
"score_breakdown": {
"blue": {
"adjustPoints": 0,
"autoPoints": 12,
"bay1": "Panel",
"bay2": "PanelAndCargo",
"bay3": "PanelAndCargo",
"bay4": "None",
"bay5": "PanelAndCargo",
"bay6": "PanelAndCargo",
"bay7": "PanelAndCargo",
"bay8": "PanelAndCargo",
"cargoPoints": 18,
"completeRocketRankingPoint": false,
"completedRocketFar": false,
"completedRocketNear": false,
"endgameRobot1": "HabLevel1",
"endgameRobot2": "HabLevel3",
"endgameRobot3": "HabLevel1",
"foulCount": 0,
"foulPoints": 0,
"habClimbPoints": 18,
"habDockingRankingPoint": false,
"habLineRobot1": "CrossedHabLineInSandstorm",
"habLineRobot2": "CrossedHabLineInSandstorm",
"habLineRobot3": "CrossedHabLineInSandstorm",
"hatchPanelPoints": 2,
"lowLeftRocketFar": "None",
"lowLeftRocketNear": "None",
"lowRightRocketFar": "None",
"lowRightRocketNear": "None",
"midLeftRocketFar": "None",
"midLeftRocketNear": "None",
"midRightRocketFar": "None",
"midRightRocketNear": "None",
"preMatchBay1": "Panel",
"preMatchBay2": "Panel",
"preMatchBay3": "Panel",
"preMatchBay6": "Panel",
"preMatchBay7": "Panel",
"preMatchBay8": "Panel",
"preMatchLevelRobot1": "HabLevel1",
"preMatchLevelRobot2": "HabLevel1",
"preMatchLevelRobot3": "HabLevel2",
"rp": 0,
"sandStormBonusPoints": 12,
"techFoulCount": 0,
"teleopPoints": 38,
"topLeftRocketFar": "None",
"topLeftRocketNear": "None",
"topRightRocketFar": "None",
"topRightRocketNear": "None",
"totalPoints": 50
},
"red": {
"adjustPoints": 0,
"autoPoints": 9,
"bay1": "Panel",
"bay2": "Panel",
"bay3": "Panel",
"bay4": "Panel",
"bay5": "PanelAndCargo",
"bay6": "Panel",
"bay7": "Panel",
"bay8": "Panel",
"cargoPoints": 3,
"completeRocketRankingPoint": false,
"completedRocketFar": false,
"completedRocketNear": false,
"endgameRobot1": "HabLevel2",
"endgameRobot2": "HabLevel1",
"endgameRobot3": "HabLevel1",
"foulCount": 0,
"foulPoints": 0,
"habClimbPoints": 12,
"habDockingRankingPoint": false,
"habLineRobot1": "CrossedHabLineInSandstorm",
"habLineRobot2": "CrossedHabLineInSandstorm",
"habLineRobot3": "CrossedHabLineInTeleop",
"hatchPanelPoints": 8,
"lowLeftRocketFar": "Panel",
"lowLeftRocketNear": "None",
"lowRightRocketFar": "Panel",
"lowRightRocketNear": "None",
"midLeftRocketFar": "None",
"midLeftRocketNear": "None",
"midRightRocketFar": "None",
"midRightRocketNear": "None",
"preMatchBay1": "Panel",
"preMatchBay2": "Panel",
"preMatchBay3": "Panel",
"preMatchBay6": "Panel",
"preMatchBay7": "Panel",
"preMatchBay8": "Panel",
"preMatchLevelRobot1": "HabLevel2",
"preMatchLevelRobot2": "HabLevel1",
"preMatchLevelRobot3": "HabLevel1",
"rp": 0,
"sandStormBonusPoints": 9,
"techFoulCount": 0,
"teleopPoints": 23,
"topLeftRocketFar": "None",
"topLeftRocketNear": "None",
"topRightRocketFar": "None",
"topRightRocketNear": "None",
"totalPoints": 32
}
},
"set_number": 1,
"time": 1550345760,
"videos": [
{
"key": "ynbCsVr8_84",
"type": "youtube"
}
],
"winning_alliance": "blue"
}
148 changes: 148 additions & 0 deletions android/src/androidTest/resources/2019week0_qm6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"actual_time": 1550330637,
"alliances": {
"blue": {
"dq_team_keys": [],
"score": 47,
"surrogate_team_keys": [],
"team_keys": [
"frc1721",
"frc58",
"frc3236"
]
},
"red": {
"dq_team_keys": [],
"score": 26,
"surrogate_team_keys": [],
"team_keys": [
"frc811",
"frc3986",
"frc1729"
]
}
},
"comp_level": "qm",
"event_key": "2019week0",
"key": "2019week0_qm6",
"match_number": 6,
"post_result_time": 1550330813,
"predicted_time": 1550330766,
"score_breakdown": {
"blue": {
"adjustPoints": 0,
"autoPoints": 9,
"bay1": "Panel",
"bay2": "Panel",
"bay3": "Panel",
"bay4": "None",
"bay5": "None",
"bay6": "Panel",
"bay7": "Panel",
"bay8": "Panel",
"cargoPoints": 0,
"completeRocketRankingPoint": false,
"completedRocketFar": false,
"completedRocketNear": false,
"endgameRobot1": "HabLevel1",
"endgameRobot2": "HabLevel3",
"endgameRobot3": "HabLevel1",
"foulCount": 0,
"foulPoints": 10,
"habClimbPoints": 18,
"habDockingRankingPoint": true,
"habLineRobot1": "CrossedHabLineInSandstorm",
"habLineRobot2": "CrossedHabLineInSandstorm",
"habLineRobot3": "CrossedHabLineInSandstorm",
"hatchPanelPoints": 10,
"lowLeftRocketFar": "Panel",
"lowLeftRocketNear": "Panel",
"lowRightRocketFar": "None",
"lowRightRocketNear": "None",
"midLeftRocketFar": "Panel",
"midLeftRocketNear": "Panel",
"midRightRocketFar": "None",
"midRightRocketNear": "None",
"preMatchBay1": "Panel",
"preMatchBay2": "Panel",
"preMatchBay3": "Panel",
"preMatchBay6": "Panel",
"preMatchBay7": "Panel",
"preMatchBay8": "Panel",
"preMatchLevelRobot1": "HabLevel1",
"preMatchLevelRobot2": "HabLevel1",
"preMatchLevelRobot3": "HabLevel1",
"rp": 3,
"sandStormBonusPoints": 9,
"techFoulCount": 0,
"teleopPoints": 28,
"topLeftRocketFar": "Panel",
"topLeftRocketNear": "None",
"topRightRocketFar": "None",
"topRightRocketNear": "None",
"totalPoints": 47
},
"red": {
"adjustPoints": 0,
"autoPoints": 12,
"bay1": "None",
"bay2": "Panel",
"bay3": "PanelAndCargo",
"bay4": "None",
"bay5": "None",
"bay6": "Panel",
"bay7": "Panel",
"bay8": "Panel",
"cargoPoints": 3,
"completeRocketRankingPoint": false,
"completedRocketFar": false,
"completedRocketNear": false,
"endgameRobot1": "HabLevel1",
"endgameRobot2": "HabLevel1",
"endgameRobot3": "HabLevel1",
"foulCount": 0,
"foulPoints": 0,
"habClimbPoints": 9,
"habDockingRankingPoint": false,
"habLineRobot1": "CrossedHabLineInSandstorm",
"habLineRobot2": "CrossedHabLineInSandstorm",
"habLineRobot3": "CrossedHabLineInSandstorm",
"hatchPanelPoints": 2,
"lowLeftRocketFar": "None",
"lowLeftRocketNear": "None",
"lowRightRocketFar": "None",
"lowRightRocketNear": "None",
"midLeftRocketFar": "None",
"midLeftRocketNear": "None",
"midRightRocketFar": "None",
"midRightRocketNear": "None",
"preMatchBay1": "Cargo",
"preMatchBay2": "Panel",
"preMatchBay3": "Panel",
"preMatchBay6": "Panel",
"preMatchBay7": "Panel",
"preMatchBay8": "Panel",
"preMatchLevelRobot1": "HabLevel1",
"preMatchLevelRobot2": "HabLevel1",
"preMatchLevelRobot3": "HabLevel2",
"rp": 0,
"sandStormBonusPoints": 12,
"techFoulCount": 1,
"teleopPoints": 14,
"topLeftRocketFar": "None",
"topLeftRocketNear": "Panel",
"topRightRocketFar": "None",
"topRightRocketNear": "None",
"totalPoints": 26
}
},
"set_number": 1,
"time": 1550327700,
"videos": [
{
"key": "n3fDuqHxh7w",
"type": "youtube"
}
],
"winning_alliance": "blue"
}
Loading

0 comments on commit a6356ad

Please sign in to comment.