summaryrefslogtreecommitdiff
path: root/android/sdl_android/src
diff options
context:
space:
mode:
authorJulian Kast <Julian.kast@livio.io>2020-09-17 13:40:18 -0400
committerGitHub <noreply@github.com>2020-09-17 13:40:18 -0400
commit6e93579d490d60deb382e96ee4bc8d7581989929 (patch)
tree4ebfa7351832f0f6ff7525c077c0a116fdfcd260 /android/sdl_android/src
parentb5746a4621852c330d45e7b8fdace833c8b95d94 (diff)
downloadsdl_android-6e93579d490d60deb382e96ee4bc8d7581989929.tar.gz
[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>
Diffstat (limited to 'android/sdl_android/src')
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java110
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java197
2 files changed, 255 insertions, 52 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
index e65911ccb..58e5b8fda 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
@@ -17,10 +17,13 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.managers.ISdl;
import com.smartdevicelink.proxy.rpc.DisplayCapability;
import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.TemplateConfiguration;
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.WindowCapability;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.enums.MetadataType;
+import com.smartdevicelink.proxy.rpc.enums.PredefinedLayout;
import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
@@ -58,7 +61,8 @@ public class TextAndGraphicManagerTests {
// SETUP / HELPERS
private TextAndGraphicManager textAndGraphicManager;
- private SdlArtwork testArtwork;
+ private SdlArtwork testArtwork1, testArtwork2;
+ private TemplateConfiguration configuration1, configuration2;
@Before
public void setUp() throws Exception{
@@ -69,11 +73,20 @@ public class TextAndGraphicManagerTests {
FileManager fileManager = mock(FileManager.class);
SoftButtonManager softButtonManager = mock(SoftButtonManager.class);
- testArtwork = new SdlArtwork();
- testArtwork.setName("testFile");
+ testArtwork1 = new SdlArtwork();
+ testArtwork1.setName("testFile");
Uri uri = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl");
- testArtwork.setUri(uri);
- testArtwork.setType(FileType.GRAPHIC_PNG);
+ testArtwork1.setUri(uri);
+ testArtwork1.setType(FileType.GRAPHIC_PNG);
+
+ testArtwork2 = new SdlArtwork();
+ testArtwork2.setName("testFile2");
+ Uri uri2 = Uri.parse("android.resource://" + mTestContext.getPackageName() + "/drawable/ic_sdl");
+ testArtwork2.setUri(uri2);
+ testArtwork2.setType(FileType.GRAPHIC_PNG);
+
+ configuration1 = new TemplateConfiguration(PredefinedLayout.GRAPHIC_WITH_TEXT.toString());
+ configuration2 = new TemplateConfiguration(PredefinedLayout.DOUBLE_GRAPHIC_WITH_SOFTBUTTONS.toString());
Taskmaster taskmaster = new Taskmaster.Builder().build();
taskmaster.start();
@@ -157,7 +170,6 @@ public class TextAndGraphicManagerTests {
@Test
public void testInstantiation(){
-
assertNull(textAndGraphicManager.getTextField1());
assertNull(textAndGraphicManager.getTextField2());
assertNull(textAndGraphicManager.getTextField3());
@@ -224,14 +236,14 @@ public class TextAndGraphicManagerTests {
@Test
public void testSetPrimaryGraphic() {
- textAndGraphicManager.setPrimaryGraphic(testArtwork);
- assertEquals(textAndGraphicManager.getPrimaryGraphic(), testArtwork);
+ textAndGraphicManager.setPrimaryGraphic(testArtwork1);
+ assertEquals(textAndGraphicManager.getPrimaryGraphic(), testArtwork1);
}
@Test
public void testSetSecondaryGraphic() {
- textAndGraphicManager.setSecondaryGraphic(testArtwork);
- assertEquals(textAndGraphicManager.getSecondaryGraphic(), testArtwork);
+ textAndGraphicManager.setSecondaryGraphic(testArtwork1);
+ assertEquals(textAndGraphicManager.getSecondaryGraphic(), testArtwork1);
}
// TEST DISPOSE
@@ -288,7 +300,83 @@ public class TextAndGraphicManagerTests {
assertTrue(textAndGraphicManager.hasData());
textAndGraphicManager.setTextField1(null);
- textAndGraphicManager.setPrimaryGraphic(testArtwork);
+ textAndGraphicManager.setPrimaryGraphic(testArtwork1);
assertTrue(textAndGraphicManager.hasData());
}
+
+ @Test
+ public void resetFieldsToCurrentScreenDataTest() {
+ textAndGraphicManager.setTextField1("textField1");
+ textAndGraphicManager.setTextField2("textField2");
+ textAndGraphicManager.setTextField3("textField3");
+ textAndGraphicManager.setTextField4("textField4");
+ textAndGraphicManager.setTextField1Type(MetadataType.MEDIA_TITLE);
+ textAndGraphicManager.setTextField2Type(MetadataType.MEDIA_TITLE);
+ textAndGraphicManager.setTextField3Type(MetadataType.MEDIA_TITLE);
+ textAndGraphicManager.setTextField4Type(MetadataType.MEDIA_TITLE);
+ textAndGraphicManager.setMediaTrackTextField("mediaTrackTextField");
+ textAndGraphicManager.setTitle("title");
+ textAndGraphicManager.setPrimaryGraphic(testArtwork1);
+ textAndGraphicManager.setSecondaryGraphic(testArtwork2);
+ textAndGraphicManager.changeLayout(configuration1, null);
+ textAndGraphicManager.currentScreenData = textAndGraphicManager.currentState();
+
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField1().equals(textAndGraphicManager.getTextField1()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField2().equals(textAndGraphicManager.getTextField2()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField3().equals(textAndGraphicManager.getTextField3()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField4().equals(textAndGraphicManager.getTextField4()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTitle().equals(textAndGraphicManager.getTitle()));
+ assertTrue(textAndGraphicManager.currentScreenData.getMediaTrackTextField().equals(textAndGraphicManager.getMediaTrackTextField()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField1Type().toString().equals(textAndGraphicManager.getTextField1Type().toString()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField2Type().toString().equals(textAndGraphicManager.getTextField2Type().toString()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField3Type().toString().equals(textAndGraphicManager.getTextField3Type().toString()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField4Type().toString().equals(textAndGraphicManager.getTextField4Type().toString()));
+ assertTrue(textAndGraphicManager.currentScreenData.getPrimaryGraphic().getName().equals(textAndGraphicManager.getPrimaryGraphic().getName()));
+ assertTrue(textAndGraphicManager.currentScreenData.getSecondaryGraphic().getName().equals(textAndGraphicManager.getSecondaryGraphic().getName()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTemplateConfiguration().getStore().equals(textAndGraphicManager.getTemplateConfiguration().getStore()));
+
+ textAndGraphicManager.setTextField1("BadData");
+ textAndGraphicManager.setTextField2("BadData");
+ textAndGraphicManager.setTextField3("BadData");
+ textAndGraphicManager.setTextField4("BadData");
+ textAndGraphicManager.setTextField1Type(MetadataType.HUMIDITY);
+ textAndGraphicManager.setTextField2Type(MetadataType.HUMIDITY);
+ textAndGraphicManager.setTextField3Type(MetadataType.HUMIDITY);
+ textAndGraphicManager.setTextField4Type(MetadataType.HUMIDITY);
+ textAndGraphicManager.setMediaTrackTextField("BadData");
+ textAndGraphicManager.setTitle("BadData");
+ textAndGraphicManager.setPrimaryGraphic(testArtwork2);
+ textAndGraphicManager.setSecondaryGraphic(testArtwork1);
+ textAndGraphicManager.changeLayout(configuration2, null);
+
+ assertFalse(textAndGraphicManager.currentScreenData.getTextField1().equals(textAndGraphicManager.getTextField1()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTextField2().equals(textAndGraphicManager.getTextField2()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTextField3().equals(textAndGraphicManager.getTextField3()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTextField4().equals(textAndGraphicManager.getTextField4()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTitle().equals(textAndGraphicManager.getTitle()));
+ assertFalse(textAndGraphicManager.currentScreenData.getMediaTrackTextField().equals(textAndGraphicManager.getMediaTrackTextField()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTextField1Type().toString().equals(textAndGraphicManager.getTextField1Type().toString()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTextField2Type().toString().equals(textAndGraphicManager.getTextField2Type().toString()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTextField3Type().toString().equals(textAndGraphicManager.getTextField3Type().toString()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTextField4Type().toString().equals(textAndGraphicManager.getTextField4Type().toString()));
+ assertFalse(textAndGraphicManager.currentScreenData.getPrimaryGraphic().getName().equals(textAndGraphicManager.getPrimaryGraphic().getName()));
+ assertFalse(textAndGraphicManager.currentScreenData.getSecondaryGraphic().getName().equals(textAndGraphicManager.getSecondaryGraphic().getName()));
+ assertFalse(textAndGraphicManager.currentScreenData.getTemplateConfiguration().getStore().equals(textAndGraphicManager.getTemplateConfiguration().getStore()));
+
+ textAndGraphicManager.resetFieldsToCurrentScreenData();
+
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField1().equals(textAndGraphicManager.getTextField1()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField2().equals(textAndGraphicManager.getTextField2()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField3().equals(textAndGraphicManager.getTextField3()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField4().equals(textAndGraphicManager.getTextField4()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTitle().equals(textAndGraphicManager.getTitle()));
+ assertTrue(textAndGraphicManager.currentScreenData.getMediaTrackTextField().equals(textAndGraphicManager.getMediaTrackTextField()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField1Type().toString().equals(textAndGraphicManager.getTextField1Type().toString()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField2Type().toString().equals(textAndGraphicManager.getTextField2Type().toString()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField3Type().toString().equals(textAndGraphicManager.getTextField3Type().toString()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTextField4Type().toString().equals(textAndGraphicManager.getTextField4Type().toString()));
+ assertTrue(textAndGraphicManager.currentScreenData.getPrimaryGraphic().getName().equals(textAndGraphicManager.getPrimaryGraphic().getName()));
+ assertTrue(textAndGraphicManager.currentScreenData.getSecondaryGraphic().getName().equals(textAndGraphicManager.getSecondaryGraphic().getName()));
+ assertTrue(textAndGraphicManager.currentScreenData.getTemplateConfiguration().getStore().equals(textAndGraphicManager.getTemplateConfiguration().getStore()));
+ }
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java
index 94f75d764..e00ce9b02 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicUpdateOperationTest.java
@@ -17,13 +17,17 @@ import com.smartdevicelink.managers.ISdl;
import com.smartdevicelink.proxy.rpc.ImageField;
import com.smartdevicelink.proxy.rpc.MetadataTags;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
+import com.smartdevicelink.proxy.rpc.SetDisplayLayout;
+import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
import com.smartdevicelink.proxy.rpc.Show;
import com.smartdevicelink.proxy.rpc.ShowResponse;
+import com.smartdevicelink.proxy.rpc.TemplateConfiguration;
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.WindowCapability;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
import com.smartdevicelink.proxy.rpc.enums.MetadataType;
+import com.smartdevicelink.proxy.rpc.enums.PredefinedLayout;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
@@ -57,10 +61,11 @@ public class TextAndGraphicUpdateOperationTest {
private SdlArtwork testArtwork1, testArtwork2, testArtwork3, testArtwork4;
private TextAlignment textAlignment;
private WindowCapability defaultMainWindowCapability;
- private Show currentScreenData;
+ private TextAndGraphicState currentScreenData;
private CompletionListener listener;
private TextAndGraphicManager.CurrentScreenDataUpdatedListener currentScreenDataUpdatedListener;
private SdlArtwork blankArtwork;
+ private TemplateConfiguration configuration;
ISdl internalInterface;
FileManager fileManager;
@@ -79,6 +84,52 @@ public class TextAndGraphicUpdateOperationTest {
}
};
+ private Answer<Void> onShowFail = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ RPCRequest message = (RPCRequest) args[0];
+ if (message instanceof Show) {
+ int correlationId = message.getCorrelationID();
+ ShowResponse showResponse = new ShowResponse();
+ showResponse.setSuccess(false);
+ message.getOnRPCResponseListener().onResponse(correlationId, showResponse);
+ }
+ return null;
+ }
+ };
+
+ private Answer<Void> onSetDisplayLayoutSuccess = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ RPCRequest message = (RPCRequest) args[0];
+ if (message instanceof SetDisplayLayout) {
+ int correlationId = message.getCorrelationID();
+ SetDisplayLayoutResponse setDisplayLayoutResponse = new SetDisplayLayoutResponse();
+ setDisplayLayoutResponse.setSuccess(true);
+ message.getOnRPCResponseListener().onResponse(correlationId, setDisplayLayoutResponse);
+ }
+ return null;
+ }
+ };
+
+ private Answer<Void> onSetDisplayLayoutCanceled = new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) {
+ Object[] args = invocation.getArguments();
+ RPCRequest message = (RPCRequest) args[0];
+ if (message instanceof SetDisplayLayout) {
+ int correlationId = message.getCorrelationID();
+ textAndGraphicUpdateOperation.cancelTask();
+ SetDisplayLayoutResponse setDisplayLayoutResponse = new SetDisplayLayoutResponse();
+ setDisplayLayoutResponse.setSuccess(true);
+ message.getOnRPCResponseListener().onResponse(correlationId, setDisplayLayoutResponse);
+ }
+ return null;
+ }
+ };
+
private Answer<Void> onShowSuccessCanceled = new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
@@ -170,26 +221,35 @@ public class TextAndGraphicUpdateOperationTest {
testArtwork4.setUri(uri4);
testArtwork4.setType(FileType.GRAPHIC_PNG);
- currentScreenData = new Show();
- currentScreenData.setMainField1("Old");
- currentScreenData.setMainField2("Text");
- currentScreenData.setMainField3("Not");
- currentScreenData.setMainField4("Important");
+ configuration = new TemplateConfiguration();
+ configuration.setTemplate(PredefinedLayout.GRAPHIC_WITH_TEXT.toString());
+
+ currentScreenData = new TextAndGraphicState();
+ currentScreenData.setTextField1("Old");
+ currentScreenData.setTextField2("Text");
+ currentScreenData.setTextField3("Not");
+ currentScreenData.setTextField4("Important");
- currentScreenData.setGraphic(testArtwork1.getImageRPC());
- currentScreenData.setSecondaryGraphic(testArtwork2.getImageRPC());
+ currentScreenData.setPrimaryGraphic(testArtwork1);
+ currentScreenData.setSecondaryGraphic(testArtwork2);
+ currentScreenData.setTemplateConfiguration(configuration);
currentScreenDataUpdatedListener = new TextAndGraphicManager.CurrentScreenDataUpdatedListener() {
@Override
- public void onUpdate(Show show) {
+ public void onUpdate(TextAndGraphicState newState) {
+
+ }
+
+ @Override
+ public void onError() {
}
};
defaultMainWindowCapability = getWindowCapability(4);
- TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4,
- mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, null);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
}
@@ -266,29 +326,29 @@ public class TextAndGraphicUpdateOperationTest {
// Test Images need to be uploaded, sending text and uploading images
textAndGraphicUpdateOperation.onExecute();
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1);
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField2(), textField2);
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField3(), textField3);
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField4(), textField4);
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getAlignment(), textAlignment);
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getGraphic(), testArtwork3.getImageRPC());
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getSecondaryGraphic(), testArtwork4.getImageRPC());
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextField1(), textField1);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextField2(), textField2);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextField3(), textField3);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextField4(), textField4);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextAlignment(), textAlignment);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getPrimaryGraphic(), testArtwork3);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getSecondaryGraphic(), testArtwork4);
// Test The files to be updated are already uploaded, send the full show immediately
String textField11 = "It's not";
- TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField11, textField2, textField3, textField4,
- mediaTrackField, title, testArtwork1, testArtwork2, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField11, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork1, testArtwork2, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, null);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
textAndGraphicUpdateOperation.onExecute();
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField11);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextField1(), textField11);
//Test: If there are no images to update, just send the text
- TextsAndGraphicsState textsAndGraphicsStateNullImages = new TextsAndGraphicsState(textField1, textField2, textField3, textField4,
- mediaTrackField, title, blankArtwork, blankArtwork, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ TextAndGraphicState textsAndGraphicsStateNullImages = new TextAndGraphicState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, blankArtwork, blankArtwork, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, null);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsStateNullImages, listener, currentScreenDataUpdatedListener);
textAndGraphicUpdateOperation.onExecute();
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextField1(), textField1);
// Verifies that uploadArtworks gets called only with the fist textAndGraphicsUpdateOperation.onExecute call
verify(fileManager, times(1)).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class));
@@ -298,7 +358,7 @@ public class TextAndGraphicUpdateOperationTest {
public void testCanceledRightAway() {
textAndGraphicUpdateOperation.cancelTask();
textAndGraphicUpdateOperation.onExecute();
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), "Old");
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextField1(), "Old");
}
@Test
@@ -310,7 +370,7 @@ public class TextAndGraphicUpdateOperationTest {
// Test Canceled after Image upload
textAndGraphicUpdateOperation.onExecute();
verify(internalInterface, times(1)).sendRPC(any(Show.class));
- assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getMainField1(), textField1);
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTextField1(), textField1);
}
@@ -324,6 +384,22 @@ public class TextAndGraphicUpdateOperationTest {
}
+ @Test
+ public void testTaskCanceledAfterSetDisplayLayout() {
+ doAnswer(onSetDisplayLayoutCanceled).when(internalInterface).sendRPC(any(SetDisplayLayout.class));
+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 0));
+
+ TemplateConfiguration configuration = new TemplateConfiguration().setTemplate(PredefinedLayout.DOUBLE_GRAPHIC_WITH_SOFTBUTTONS.toString());
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, configuration);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ textAndGraphicUpdateOperation.onExecute();
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTemplateConfiguration().getStore(), configuration.getStore());
+ verify(internalInterface, times(0)).sendRPC(any(Show.class));
+ }
+
+
+
/**
* Test getting number of lines available to be set based off of windowCapability
*/
@@ -348,8 +424,8 @@ public class TextAndGraphicUpdateOperationTest {
Show inputShow = new Show();
- TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
- mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null, null);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, getWindowCapability(1), currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
@@ -404,8 +480,8 @@ public class TextAndGraphicUpdateOperationTest {
defaultMainWindowCapability = getWindowCapability(2);
// Force it to return display with support for only 2 lines of text
- TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
- mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null, null);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
@@ -507,8 +583,8 @@ public class TextAndGraphicUpdateOperationTest {
// Force it to return display with support for only 3 lines of text
defaultMainWindowCapability = getWindowCapability(3);
- TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
- mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null, null);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
Show assembledShow = textAndGraphicUpdateOperation.assembleShowText(inputShow);
@@ -621,8 +697,8 @@ public class TextAndGraphicUpdateOperationTest {
List<TextField> textFieldNames = Arrays.asList(tx1, tx2, tx3, tx4, tx5, tx6);
defaultMainWindowCapability.setTextFields(textFieldNames);
- TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
- mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null, null);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
textsAndGraphicsState.setMediaTrackTextField("HI");
textsAndGraphicsState.setTitle("bye");
@@ -741,8 +817,8 @@ public class TextAndGraphicUpdateOperationTest {
Show inputShow = new Show();
- TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, null, null, null,
- mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null);
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, null, null, null,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, MetadataType.HUMIDITY, null, null, null, null);
textsAndGraphicsState.setMediaTrackTextField("HI");
textsAndGraphicsState.setTitle("bye");
@@ -867,7 +943,7 @@ public class TextAndGraphicUpdateOperationTest {
mainShow.setMainField3("Sauce");
mainShow.setMainField4("");
- Show newShow = textAndGraphicUpdateOperation.extractTextFromShow(mainShow);
+ Show newShow = textAndGraphicUpdateOperation.extractTextAndLayoutFromShow(mainShow);
assertEquals(newShow.getMainField1(), "test");
assertEquals(newShow.getMainField3(), "Sauce");
@@ -883,20 +959,59 @@ public class TextAndGraphicUpdateOperationTest {
// Test when artwork hasn't been uploaded
when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(false);
- TextsAndGraphicsState textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4,
- mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, configuration);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(testArtwork1, testArtwork2);
assertNull(testShow);
// Test when artwork has been uploaded
when(fileManager.hasUploadedFile(any(SdlFile.class))).thenReturn(true);
- textsAndGraphicsState = new TextsAndGraphicsState(textField1, textField2, textField3, textField4,
- mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type);
+ textsAndGraphicsState = new TextAndGraphicState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, configuration);
textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
testShow = textAndGraphicUpdateOperation.createImageOnlyShowWithPrimaryArtwork(testArtwork1, testArtwork2);
assertEquals(testShow.getGraphic(), testArtwork1.getImageRPC());
assertEquals(testShow.getSecondaryGraphic(), testArtwork2.getImageRPC());
}
+ @Test
+ public void testTemplateChange() {
+ doAnswer(onShowSuccess).when(internalInterface).sendRPC(any(Show.class));
+ doAnswer(onSetDisplayLayoutSuccess).when(internalInterface).sendRPC(any(SetDisplayLayout.class));
+ doAnswer(onArtworkUploadSuccess).when(fileManager).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class));
+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
+
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, configuration);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ textAndGraphicUpdateOperation.onExecute();
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTemplateConfiguration().getStore(), configuration.getStore());
+
+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(5, 0));
+
+ TemplateConfiguration configuration2 = new TemplateConfiguration().setTemplate(PredefinedLayout.DOUBLE_GRAPHIC_WITH_SOFTBUTTONS.toString());
+ textsAndGraphicsState = new TextAndGraphicState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, configuration2);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ textAndGraphicUpdateOperation.onExecute();
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTemplateConfiguration().getStore(), configuration2.getStore());
+ }
+
+ @Test
+ public void testOnShowFail() {
+ doAnswer(onShowFail).when(internalInterface).sendRPC(any(Show.class));
+ when(internalInterface.getSdlMsgVersion()).thenReturn(new SdlMsgVersion(6, 0));
+
+ TextAndGraphicState textsAndGraphicsState = new TextAndGraphicState(textField1, textField2, textField3, textField4,
+ mediaTrackField, title, testArtwork3, testArtwork4, textAlignment, textField1Type, textField2Type, textField3Type, textField4Type, configuration);
+ textAndGraphicUpdateOperation = new TextAndGraphicUpdateOperation(internalInterface, fileManager, defaultMainWindowCapability, currentScreenData, textsAndGraphicsState, listener, currentScreenDataUpdatedListener);
+ textAndGraphicUpdateOperation.onExecute();
+ assertEquals(textAndGraphicUpdateOperation.getCurrentScreenData().getTemplateConfiguration().getStore(), configuration.getStore());
+
+ // Verifies that uploadArtworks does not get called because a sendShow failed with text and layout change
+ verify(fileManager, times(0)).uploadArtworks(any(List.class), any(MultipleFileCompletionListener.class));
+
+ }
+
}