Skip to content

Commit 6e93579

Browse files
JulianKastJulian Kast
andauthored
[SDL 0278] Screen Manager Template Management (#1492)
* Work in Progress * BaseTextAndGraphicsManager changes * TextAndGraphicsUpdateOperation updates for template management * TextAndGraphicsState updates for template managment * remove comment and fix existing unit test * Added getTemplateConfiguration method and made currentState method package private * Add test to TextAndGraphicManagerTest * Fix unit test and remove commented out code * Fix test to expand code cov * Remove added constructors and use chainable setters * Fix error in shouldUpdateTemplateConfig method * Added unit test to test template change * Added unit test * Added check to cancel the operation if text / layout changes and images still need to be uploaded * Add unit test for if a show fails * Added comments and simplified logic * Fix comparing TemplateConfigurations * Add comments and fix formatting * Add java Docs to baseScreenManager * Change name of var and fix formatiing * Added final to vars that go reverted when fixing merge conflicts * Add @nonnull to templateConfiguration * Removing sending newScreenData to updatePendingOperationsWithNewScreenData as it is equal to currentScreenData at this point * Make setLayout var local * Fixing error where setDisplayLayout dosn't call listener if it fails * Added showRPCSupportsTemplateConfiguration() Method to T&G update operation * Added check to make sure we don't get an npe if internalInterface is null * added check to make sure we don't send an unnecessary templateConfig with show * Fixed issue with setDisplayLayout request updating capabilities when request fails * Documentation updates to screenManager * Formatting fix * Fix javaDocs and comments * Fixed issue with updateCurrentScreenDataFromShow * Change TextsAndGraphicsState to TextAndGraphicState to align with IOS Co-authored-by: Julian Kast <julian@livio.com>
1 parent b5746a4 commit 6e93579

7 files changed

Lines changed: 605 additions & 140 deletions

File tree

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java

Lines changed: 99 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
import com.smartdevicelink.managers.ISdl;
1818
import com.smartdevicelink.proxy.rpc.DisplayCapability;
1919
import com.smartdevicelink.proxy.rpc.OnHMIStatus;
20+
import com.smartdevicelink.proxy.rpc.TemplateConfiguration;
2021
import com.smartdevicelink.proxy.rpc.TextField;
2122
import com.smartdevicelink.proxy.rpc.WindowCapability;
2223
import com.smartdevicelink.proxy.rpc.enums.FileType;
2324
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
25+
import com.smartdevicelink.proxy.rpc.enums.MetadataType;
26+
import com.smartdevicelink.proxy.rpc.enums.PredefinedLayout;
2427
import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
2528
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
2629
import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
@@ -58,7 +61,8 @@ public class TextAndGraphicManagerTests {
5861

5962
// SETUP / HELPERS
6063
private TextAndGraphicManager textAndGraphicManager;
61-
private SdlArtwork testArtwork;
64+
private SdlArtwork testArtwork1, testArtwork2;
65+
private TemplateConfiguration configuration1, configuration2;
6266

6367
@Before
6468
public void setUp() throws Exception{
@@ -69,11 +73,20 @@ public void setUp() throws Exception{
6973
FileManager fileManager = mock(FileManager.class);
7074
SoftButtonManager softButtonManager = mock(SoftButtonManager.class);
7175

72-
testArtwork = new SdlArtwork();
73-
testArtwork.setName("testFile");
76+
testArtwork1 = new SdlArtwork();
77+
testArtwork1.setName("testFile");
7478
Uri uri = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl");
75-
testArtwork.setUri(uri);
76-
testArtwork.setType(FileType.GRAPHIC_PNG);
79+
testArtwork1.setUri(uri);
80+
testArtwork1.setType(FileType.GRAPHIC_PNG);
81+
82+
testArtwork2 = new SdlArtwork();
83+
testArtwork2.setName("testFile2");
84+
Uri uri2 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl");
85+
testArtwork2.setUri(uri2);
86+
testArtwork2.setType(FileType.GRAPHIC_PNG);
87+
88+
configuration1 = new TemplateConfiguration(PredefinedLayout.GRAPHIC_WITH_TEXT.toString());
89+
configuration2 = new TemplateConfiguration(PredefinedLayout.DOUBLE_GRAPHIC_WITH_SOFTBUTTONS.toString());
7790

7891
Taskmaster taskmaster = new Taskmaster.Builder().build();
7992
taskmaster.start();
@@ -157,7 +170,6 @@ private WindowCapability getNullVarWindowCapability() {
157170

158171
@Test
159172
public void testInstantiation(){
160-
161173
assertNull(textAndGraphicManager.getTextField1());
162174
assertNull(textAndGraphicManager.getTextField2());
163175
assertNull(textAndGraphicManager.getTextField3());
@@ -224,14 +236,14 @@ public void testAlignment() {
224236

225237
@Test
226238
public void testSetPrimaryGraphic() {
227-
textAndGraphicManager.setPrimaryGraphic(testArtwork);
228-
assertEquals(textAndGraphicManager.getPrimaryGraphic(), testArtwork);
239+
textAndGraphicManager.setPrimaryGraphic(testArtwork1);
240+
assertEquals(textAndGraphicManager.getPrimaryGraphic(), testArtwork1);
229241
}
230242

231243
@Test
232244
public void testSetSecondaryGraphic() {
233-
textAndGraphicManager.setSecondaryGraphic(testArtwork);
234-
assertEquals(textAndGraphicManager.getSecondaryGraphic(), testArtwork);
245+
textAndGraphicManager.setSecondaryGraphic(testArtwork1);
246+
assertEquals(textAndGraphicManager.getSecondaryGraphic(), testArtwork1);
235247
}
236248

237249
// TEST DISPOSE
@@ -288,7 +300,83 @@ public void testHasData() {
288300
assertTrue(textAndGraphicManager.hasData());
289301

290302
textAndGraphicManager.setTextField1(null);
291-
textAndGraphicManager.setPrimaryGraphic(testArtwork);
303+
textAndGraphicManager.setPrimaryGraphic(testArtwork1);
292304
assertTrue(textAndGraphicManager.hasData());
293305
}
306+
307+
@Test
308+
public void resetFieldsToCurrentScreenDataTest() {
309+
textAndGraphicManager.setTextField1("textField1");
310+
textAndGraphicManager.setTextField2("textField2");
311+
textAndGraphicManager.setTextField3("textField3");
312+
textAndGraphicManager.setTextField4("textField4");
313+
textAndGraphicManager.setTextField1Type(MetadataType.MEDIA_TITLE);
314+
textAndGraphicManager.setTextField2Type(MetadataType.MEDIA_TITLE);
315+
textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_TITLE);
316+
textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_TITLE);
317+
textAndGraphicManager.setMediaTrackTextField("mediaTrackTextField");
318+
textAndGraphicManager.setTitle("title");
319+
textAndGraphicManager.setPrimaryGraphic(testArtwork1);
320+
textAndGraphicManager.setSecondaryGraphic(testArtwork2);
321+
textAndGraphicManager.changeLayout(configuration1, null);
322+
textAndGraphicManager.currentScreenData = textAndGraphicManager.currentState();
323+
324+
assertTrue(textAndGraphicManager.currentScreenData.getTextField1().equals(textAndGraphicManager.getTextField1()));
325+
assertTrue(textAndGraphicManager.currentScreenData.getTextField2().equals(textAndGraphicManager.getTextField2()));
326+
assertTrue(textAndGraphicManager.currentScreenData.getTextField3().equals(textAndGraphicManager.getTextField3()));
327+
assertTrue(textAndGraphicManager.currentScreenData.getTextField4().equals(textAndGraphicManager.getTextField4()));
328+
assertTrue(textAndGraphicManager.currentScreenData.getTitle().equals(textAndGraphicManager.getTitle()));
329+
assertTrue(textAndGraphicManager.currentScreenData.getMediaTrackTextField().equals(textAndGraphicManager.getMediaTrackTextField()));
330+
assertTrue(textAndGraphicManager.currentScreenData.getTextField1Type().toString().equals(textAndGraphicManager.getTextField1Type().toString()));
331+
assertTrue(textAndGraphicManager.currentScreenData.getTextField2Type().toString().equals(textAndGraphicManager.getTextField2Type().toString()));
332+
assertTrue(textAndGraphicManager.currentScreenData.getTextField3Type().toString().equals(textAndGraphicManager.getTextField3Type().toString()));
333+
assertTrue(textAndGraphicManager.currentScreenData.getTextField4Type().toString().equals(textAndGraphicManager.getTextField4Type().toString()));
334+
assertTrue(textAndGraphicManager.currentScreenData.getPrimaryGraphic().getName().equals(textAndGraphicManager.getPrimaryGraphic().getName()));
335+
assertTrue(textAndGraphicManager.currentScreenData.getSecondaryGraphic().getName().equals(textAndGraphicManager.getSecondaryGraphic().getName()));
336+
assertTrue(textAndGraphicManager.currentScreenData.getTemplateConfiguration().getStore().equals(textAndGraphicManager.getTemplateConfiguration().getStore()));
337+
338+
textAndGraphicManager.setTextField1("BadData");
339+
textAndGraphicManager.setTextField2("BadData");
340+
textAndGraphicManager.setTextField3("BadData");
341+
textAndGraphicManager.setTextField4("BadData");
342+
textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY);
343+
textAndGraphicManager.setTextField2Type(MetadataType.HUMIDITY);
344+
textAndGraphicManager.setTextField3Type(MetadataType.HUMIDITY);
345+
textAndGraphicManager.setTextField4Type(MetadataType.HUMIDITY);
346+
textAndGraphicManager.setMediaTrackTextField("BadData");
347+
textAndGraphicManager.setTitle("BadData");
348+
textAndGraphicManager.setPrimaryGraphic(testArtwork2);
349+
textAndGraphicManager.setSecondaryGraphic(testArtwork1);
350+
textAndGraphicManager.changeLayout(configuration2, null);
351+
352+
assertFalse(textAndGraphicManager.currentScreenData.getTextField1().equals(textAndGraphicManager.getTextField1()));
353+
assertFalse(textAndGraphicManager.currentScreenData.getTextField2().equals(textAndGraphicManager.getTextField2()));
354+
assertFalse(textAndGraphicManager.currentScreenData.getTextField3().equals(textAndGraphicManager.getTextField3()));
355+
assertFalse(textAndGraphicManager.currentScreenData.getTextField4().equals(textAndGraphicManager.getTextField4()));
356+
assertFalse(textAndGraphicManager.currentScreenData.getTitle().equals(textAndGraphicManager.getTitle()));
357+
assertFalse(textAndGraphicManager.currentScreenData.getMediaTrackTextField().equals(textAndGraphicManager.getMediaTrackTextField()));
358+
assertFalse(textAndGraphicManager.currentScreenData.getTextField1Type().toString().equals(textAndGraphicManager.getTextField1Type().toString()));
359+
assertFalse(textAndGraphicManager.currentScreenData.getTextField2Type().toString().equals(textAndGraphicManager.getTextField2Type().toString()));
360+
assertFalse(textAndGraphicManager.currentScreenData.getTextField3Type().toString().equals(textAndGraphicManager.getTextField3Type().toString()));
361+
assertFalse(textAndGraphicManager.currentScreenData.getTextField4Type().toString().equals(textAndGraphicManager.getTextField4Type().toString()));
362+
assertFalse(textAndGraphicManager.currentScreenData.getPrimaryGraphic().getName().equals(textAndGraphicManager.getPrimaryGraphic().getName()));
363+
assertFalse(textAndGraphicManager.currentScreenData.getSecondaryGraphic().getName().equals(textAndGraphicManager.getSecondaryGraphic().getName()));
364+
assertFalse(textAndGraphicManager.currentScreenData.getTemplateConfiguration().getStore().equals(textAndGraphicManager.getTemplateConfiguration().getStore()));
365+
366+
textAndGraphicManager.resetFieldsToCurrentScreenData();
367+
368+
assertTrue(textAndGraphicManager.currentScreenData.getTextField1().equals(textAndGraphicManager.getTextField1()));
369+
assertTrue(textAndGraphicManager.currentScreenData.getTextField2().equals(textAndGraphicManager.getTextField2()));
370+
assertTrue(textAndGraphicManager.currentScreenData.getTextField3().equals(textAndGraphicManager.getTextField3()));
371+
assertTrue(textAndGraphicManager.currentScreenData.getTextField4().equals(textAndGraphicManager.getTextField4()));
372+
assertTrue(textAndGraphicManager.currentScreenData.getTitle().equals(textAndGraphicManager.getTitle()));
373+
assertTrue(textAndGraphicManager.currentScreenData.getMediaTrackTextField().equals(textAndGraphicManager.getMediaTrackTextField()));
374+
assertTrue(textAndGraphicManager.currentScreenData.getTextField1Type().toString().equals(textAndGraphicManager.getTextField1Type().toString()));
375+
assertTrue(textAndGraphicManager.currentScreenData.getTextField2Type().toString().equals(textAndGraphicManager.getTextField2Type().toString()));
376+
assertTrue(textAndGraphicManager.currentScreenData.getTextField3Type().toString().equals(textAndGraphicManager.getTextField3Type().toString()));
377+
assertTrue(textAndGraphicManager.currentScreenData.getTextField4Type().toString().equals(textAndGraphicManager.getTextField4Type().toString()));
378+
assertTrue(textAndGraphicManager.currentScreenData.getPrimaryGraphic().getName().equals(textAndGraphicManager.getPrimaryGraphic().getName()));
379+
assertTrue(textAndGraphicManager.currentScreenData.getSecondaryGraphic().getName().equals(textAndGraphicManager.getSecondaryGraphic().getName()));
380+
assertTrue(textAndGraphicManager.currentScreenData.getTemplateConfiguration().getStore().equals(textAndGraphicManager.getTemplateConfiguration().getStore()));
381+
}
294382
}

0 commit comments

Comments
 (0)