Page MenuHomeWildfire Games

Cleanup of GUI-interface and test.
Needs ReviewPublic

Authored by Freagarach on Jul 13 2019, 3:14 PM.

Details

Reviewers
Nescio
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

Makes Jenkins/Vulcan a big tad happier about the GUI and its test.

Test Plan

Verify that everything is correct and nothing overlooked.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 8547
Build 13986: Vulcan BuildJenkins
Build 13985: arc lint + arc unit

Event Timeline

Freagarach created this revision.Jul 13 2019, 3:14 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 4 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|  47|  47| 	"GetResource": resource => ({
|  48|  48| 		"aiAnalysisInfluenceGroup":
|  49|  49| 			resource == "food" ? "ignore" :
|  50|    |-			resource == "wood" ? "abundant" : "sparse"
|    |  50|+				resource == "wood" ? "abundant" : "sparse"
|  51|  51| 	})
|  52|  52| };
|  53|  53| 
|    | [NORMAL] ESLintBear (space-before-function-paren):
|    | Unexpected space before function parentheses.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|  61|  61| 			"sell": { "food": 25 }
|  62|  62| 		};
|  63|  63| 	},
|  64|    |-	"PlayerHasMarket": function () { return false; }
|    |  64|+	"PlayerHasMarket": function() { return false; }
|  65|  65| });
|  66|  66| 
|  67|  67| AddMock(SYSTEM_ENTITY, IID_EndGameManager, {
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'food' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|  97|  97| 	"GetPopulationCount": function() { return 10; },
|  98|  98| 	"GetPopulationLimit": function() { return 20; },
|  99|  99| 	"GetMaxPopulation": function() { return 200; },
| 100|    |-	"GetResourceCounts": function() { return { food: 100 }; },
|    | 100|+	"GetResourceCounts": function() { return { "food": 100 }; },
| 101| 101| 	"GetPanelEntities": function() { return []; },
| 102| 102| 	"IsTrainingBlocked": function() { return false; },
| 103| 103| 	"GetState": function() { return "active"; },
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'GetBasicStatistics' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 132| 132| });
| 133| 133| 
| 134| 134| AddMock(100, IID_StatisticsTracker, {
| 135|    |-	GetBasicStatistics: function() {
|    | 135|+	"GetBasicStatistics": function() {
| 136| 136| 		return {
| 137| 137| 			"resourcesGathered": {
| 138| 138| 				"food": 100,
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'GetSequences' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 144| 144| 			"percentMapExplored": 10
| 145| 145| 		};
| 146| 146| 	},
| 147|    |-	GetSequences: function() {
|    | 147|+	"GetSequences": function() {
| 148| 148| 		return {
| 149| 149| 			"unitsTrained": [0, 10],
| 150| 150| 			"unitsLost": [0, 42],
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'IncreaseTrainedUnitsCounter' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 169| 169| 			"teamPeakPercentOfMapControlled": [0, 10]
| 170| 170| 		};
| 171| 171| 	},
| 172|    |-	IncreaseTrainedUnitsCounter: function() { return 1; },
|    | 172|+	"IncreaseTrainedUnitsCounter": function() { return 1; },
| 173| 173| 	IncreaseConstructedBuildingsCounter: function() { return 1; },
| 174| 174| 	IncreaseBuiltCivCentresCounter: function() { return 1; }
| 175| 175| });
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'IncreaseConstructedBuildingsCounter' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 170| 170| 		};
| 171| 171| 	},
| 172| 172| 	IncreaseTrainedUnitsCounter: function() { return 1; },
| 173|    |-	IncreaseConstructedBuildingsCounter: function() { return 1; },
|    | 173|+	"IncreaseConstructedBuildingsCounter": function() { return 1; },
| 174| 174| 	IncreaseBuiltCivCentresCounter: function() { return 1; }
| 175| 175| });
| 176| 176| 
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'IncreaseBuiltCivCentresCounter' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 171| 171| 	},
| 172| 172| 	IncreaseTrainedUnitsCounter: function() { return 1; },
| 173| 173| 	IncreaseConstructedBuildingsCounter: function() { return 1; },
| 174|    |-	IncreaseBuiltCivCentresCounter: function() { return 1; }
|    | 174|+	"IncreaseBuiltCivCentresCounter": function() { return 1; }
| 175| 175| });
| 176| 176| 
| 177| 177| AddMock(101, IID_Player, {
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 177| 177| AddMock(101, IID_Player, {
| 178| 178| 	"GetName": function() { return "Player 2"; },
| 179| 179| 	"GetCiv": function() { return "mace"; },
| 180|    |-	"GetColor": function() { return { "r": 1, "g": 0, "b": 0, "a": 1}; },
|    | 180|+	"GetColor": function() { return { "r": 1, "g": 0, "b": 0, "a": 1 }; },
| 181| 181| 	"CanControlAllUnits": function() { return true; },
| 182| 182| 	"GetPopulationCount": function() { return 40; },
| 183| 183| 	"GetPopulationLimit": function() { return 30; },
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'food' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 182| 182| 	"GetPopulationCount": function() { return 40; },
| 183| 183| 	"GetPopulationLimit": function() { return 30; },
| 184| 184| 	"GetMaxPopulation": function() { return 300; },
| 185|    |-	"GetResourceCounts": function() { return { food: 200 }; },
|    | 185|+	"GetResourceCounts": function() { return { "food": 200 }; },
| 186| 186| 	"GetPanelEntities": function() { return []; },
| 187| 187| 	"IsTrainingBlocked": function() { return false; },
| 188| 188| 	"GetState": function() { return "active"; },
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'r' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 267| 267| 		{
| 268| 268| 			"name": "Player 1",
| 269| 269| 			"civ": "gaia",
| 270|    |-			"color": { r:1, g:1, b:1, a:1 },
|    | 270|+			"color": { "r":1, g:1, b:1, a:1 },
| 271| 271| 			"controlsAll": false,
| 272| 272| 			"popCount": 10,
| 273| 273| 			"popLimit": 20,
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'r'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 267| 267| 		{
| 268| 268| 			"name": "Player 1",
| 269| 269| 			"civ": "gaia",
| 270|    |-			"color": { r:1, g:1, b:1, a:1 },
|    | 270|+			"color": { r: 1, g:1, b:1, a:1 },
| 271| 271| 			"controlsAll": false,
| 272| 272| 			"popCount": 10,
| 273| 273| 			"popLimit": 20,
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'g' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 267| 267| 		{
| 268| 268| 			"name": "Player 1",
| 269| 269| 			"civ": "gaia",
| 270|    |-			"color": { r:1, g:1, b:1, a:1 },
|    | 270|+			"color": { r:1, "g":1, b:1, a:1 },
| 271| 271| 			"controlsAll": false,
| 272| 272| 			"popCount": 10,
| 273| 273| 			"popLimit": 20,
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'g'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 267| 267| 		{
| 268| 268| 			"name": "Player 1",
| 269| 269| 			"civ": "gaia",
| 270|    |-			"color": { r:1, g:1, b:1, a:1 },
|    | 270|+			"color": { r:1, g: 1, b:1, a:1 },
| 271| 271| 			"controlsAll": false,
| 272| 272| 			"popCount": 10,
| 273| 273| 			"popLimit": 20,
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'b' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 267| 267| 		{
| 268| 268| 			"name": "Player 1",
| 269| 269| 			"civ": "gaia",
| 270|    |-			"color": { r:1, g:1, b:1, a:1 },
|    | 270|+			"color": { r:1, g:1, "b":1, a:1 },
| 271| 271| 			"controlsAll": false,
| 272| 272| 			"popCount": 10,
| 273| 273| 			"popLimit": 20,
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'b'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 267| 267| 		{
| 268| 268| 			"name": "Player 1",
| 269| 269| 			"civ": "gaia",
| 270|    |-			"color": { r:1, g:1, b:1, a:1 },
|    | 270|+			"color": { r:1, g:1, b: 1, a:1 },
| 271| 271| 			"controlsAll": false,
| 272| 272| 			"popCount": 10,
| 273| 273| 			"popLimit": 20,
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'a' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 267| 267| 		{
| 268| 268| 			"name": "Player 1",
| 269| 269| 			"civ": "gaia",
| 270|    |-			"color": { r:1, g:1, b:1, a:1 },
|    | 270|+			"color": { r:1, g:1, b:1, "a":1 },
| 271| 271| 			"controlsAll": false,
| 272| 272| 			"popCount": 10,
| 273| 273| 			"popLimit": 20,
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'a'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 267| 267| 		{
| 268| 268| 			"name": "Player 1",
| 269| 269| 			"civ": "gaia",
| 270|    |-			"color": { r:1, g:1, b:1, a:1 },
|    | 270|+			"color": { r:1, g:1, b:1, a: 1 },
| 271| 271| 			"controlsAll": false,
| 272| 272| 			"popCount": 10,
| 273| 273| 			"popLimit": 20,
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'food' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 273| 273| 			"popLimit": 20,
| 274| 274| 			"popMax": 200,
| 275| 275| 			"panelEntities": [],
| 276|    |-			"resourceCounts": { food: 100 },
|    | 276|+			"resourceCounts": { "food": 100 },
| 277| 277| 			"trainingBlocked": false,
| 278| 278| 			"state": "active",
| 279| 279| 			"team": -1,
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'food' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 322| 322| 			"popLimit": 30,
| 323| 323| 			"popMax": 300,
| 324| 324| 			"panelEntities": [],
| 325|    |-			"resourceCounts": { food: 200 },
|    | 325|+			"resourceCounts": { "food": 200 },
| 326| 326| 			"trainingBlocked": false,
| 327| 327| 			"state": "active",
| 328| 328| 			"team": -1,
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'GetEntitiesList' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
| 524| 524| 
| 525| 525| 
| 526| 526| AddMock(10, IID_Builder, {
| 527|    |-	GetEntitiesList: function() {
|    | 527|+	"GetEntitiesList": function() {
| 528| 528| 		return ["test1", "test2"];
| 529| 529| 	},
| 530| 530| });
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 2.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|1359|1359| 						"excludeFromResult": true
|1360|1360| 					});
|1361|1361| 			}
|1362|    |-		else
|    |1362|+			else
|1363|1363| 			previewEntities.push({
|1364|1364| 				"template": wallSet.templates.tower,
|1365|1365| 				"pos": end.pos,
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 4 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|1360|1360| 					});
|1361|1361| 			}
|1362|1362| 		else
|1363|    |-			previewEntities.push({
|    |1363|+				previewEntities.push({
|1364|1364| 				"template": wallSet.templates.tower,
|1365|1365| 				"pos": end.pos,
|1366|1366| 				"angle": previewEntities.length > 0 ? previewEntities[previewEntities.length-1].angle : this.placementWallLastAngle
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 5 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|1361|1361| 			}
|1362|1362| 		else
|1363|1363| 			previewEntities.push({
|1364|    |-				"template": wallSet.templates.tower,
|    |1364|+					"template": wallSet.templates.tower,
|1365|1365| 				"pos": end.pos,
|1366|1366| 				"angle": previewEntities.length > 0 ? previewEntities[previewEntities.length-1].angle : this.placementWallLastAngle
|1367|1367| 			});
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 5 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|1362|1362| 		else
|1363|1363| 			previewEntities.push({
|1364|1364| 				"template": wallSet.templates.tower,
|1365|    |-				"pos": end.pos,
|    |1365|+					"pos": end.pos,
|1366|1366| 				"angle": previewEntities.length > 0 ? previewEntities[previewEntities.length-1].angle : this.placementWallLastAngle
|1367|1367| 			});
|1368|1368| 	}
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 5 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|1363|1363| 			previewEntities.push({
|1364|1364| 				"template": wallSet.templates.tower,
|1365|1365| 				"pos": end.pos,
|1366|    |-				"angle": previewEntities.length > 0 ? previewEntities[previewEntities.length-1].angle : this.placementWallLastAngle
|    |1366|+					"angle": previewEntities.length > 0 ? previewEntities[previewEntities.length-1].angle : this.placementWallLastAngle
|1367|1367| 			});
|1368|1368| 	}
|1369|1369| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 4 tabs but found 3.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|1364|1364| 				"template": wallSet.templates.tower,
|1365|1365| 				"pos": end.pos,
|1366|1366| 				"angle": previewEntities.length > 0 ? previewEntities[previewEntities.length-1].angle : this.placementWallLastAngle
|1367|    |-			});
|    |1367|+				});
|1368|1368| 	}
|1369|1369| 
|1370|1370| 	let cmpTerrain = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain);
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 1.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
|1365|1365| 				"pos": end.pos,
|1366|1366| 				"angle": previewEntities.length > 0 ? previewEntities[previewEntities.length-1].angle : this.placementWallLastAngle
|1367|1367| 			});
|1368|    |-	}
|    |1368|+		}
|1369|1369| 
|1370|1370| 	let cmpTerrain = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain);
|1371|1371| 	if (!cmpTerrain)
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/50/display/redirect

Freagarach updated this revision to Diff 8863.Jul 13 2019, 9:36 PM

Some more fixes (last?).

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/54/display/redirect

Freagarach updated this revision to Diff 8864.Jul 13 2019, 9:47 PM

Reuploading because the test doesn't fail locally.

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/55/display/redirect

Nescio added a subscriber: bb.Jul 13 2019, 10:42 PM

@Nescio, you are my superior in this

Am I?
Because it involves javascript, you actually need someone else; perhaps @bb is willing to.

binaries/data/mods/public/simulation/components/GuiInterface.js
8–10

-ized
Usually I don't mind whether people use American or British spelling in comments, but using both in the same sentence is ugly.

65

which

284

let?

419–420

Shouldn't it be 2 * Math.PI?

528

idem

799–800

Aren't comments typically on a new line? (Also below.)

1144

hold

1153

idem

In D2069#86271, @Nescio wrote:

@Nescio, you are my superior in this

Am I?
Because it involves javascript, you actually need someone else; perhaps @bb is willing to.

I did not really change any code (except one var -> let) and, as far as I can tell, you are a very exact person. So yeah, I think you are ;)

binaries/data/mods/public/simulation/components/GuiInterface.js
1144

What they meant here was probably something like: "If yes, this holds (...)". I'm not even sure these comments (and below) are needed, because it seems obvious from the code, but that's not up to me ;)

Freagarach updated this revision to Diff 8878.Jul 14 2019, 7:34 AM
Freagarach marked 8 inline comments as done.

Thanks @Nescio!

  • Inlines.
  • One var => let.

and always discourage non-core members from doing wholesale commits like this for obvious reasons..

Sorry, didn't know,,,

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/67/display/redirect

Freagarach planned changes to this revision.Jul 18 2019, 5:28 PM

Wait for result of D2070 discussion. Especially regarding curly braces.

binaries/data/mods/public/simulation/components/GuiInterface.js
1148

I still managed to forget this.

Freagarach updated this revision to Diff 9078.Jul 23 2019, 11:48 AM
Freagarach edited the summary of this revision. (Show Details)
Freagarach edited the test plan for this revision. (Show Details)

Rebased after D2070.

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/202/display/redirect