1717import com .smartdevicelink .managers .ISdl ;
1818import com .smartdevicelink .proxy .rpc .DisplayCapability ;
1919import com .smartdevicelink .proxy .rpc .OnHMIStatus ;
20+ import com .smartdevicelink .proxy .rpc .TemplateConfiguration ;
2021import com .smartdevicelink .proxy .rpc .TextField ;
2122import com .smartdevicelink .proxy .rpc .WindowCapability ;
2223import com .smartdevicelink .proxy .rpc .enums .FileType ;
2324import com .smartdevicelink .proxy .rpc .enums .HMILevel ;
25+ import com .smartdevicelink .proxy .rpc .enums .MetadataType ;
26+ import com .smartdevicelink .proxy .rpc .enums .PredefinedLayout ;
2427import com .smartdevicelink .proxy .rpc .enums .SystemCapabilityType ;
2528import com .smartdevicelink .proxy .rpc .enums .TextAlignment ;
2629import 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