Skip to content

Commit 648bdc3

Browse files
committed
Cleanup code and modify tests
Remove whitespace and unused imports Change logic of tests based on #1776 feedback Rename testConstructingSoftButtonObjectWithNonEmptyStateList() to testConstructSoftButtonObjectWithNonEmptyStateList() to match naming of related tests
1 parent f95aec3 commit 648bdc3

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

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

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
3434
import com.smartdevicelink.test.Validator;
3535

36-
import org.junit.Assert;
3736
import org.junit.Before;
3837
import org.junit.Test;
3938
import org.junit.runner.RunWith;
@@ -58,14 +57,11 @@
5857
import static org.mockito.Mockito.mock;
5958
import static org.mockito.Mockito.when;
6059

61-
import android.database.sqlite.SQLiteCantOpenDatabaseException;
62-
6360
/**
6461
* This is a unit test class for the SmartDeviceLink library manager class :
6562
* {@link SoftButtonManager}
6663
*/
6764
@RunWith(AndroidJUnit4.class)
68-
//@RunWith(JUnit4.class)
6965
public class SoftButtonManagerTests {
7066

7167
private SoftButtonManager softButtonManager;
@@ -414,48 +410,55 @@ public void testSoftButtonStateEquals() {
414410
@Test
415411
public void testConstructSoftButtonObjectWithEmptyStateList() {
416412
List<SoftButtonState> stateList = new ArrayList<>();
417-
SoftButtonObject softButtonObject1 = new SoftButtonObject("hello_there", stateList, "general_kenobi", null);
418-
assertNull(softButtonObject1.getStates());
413+
SoftButtonObject softButtonObject = new SoftButtonObject("hello_there", stateList, "general_kenobi", null);
414+
assertNull(softButtonObject.getStates());
419415
}
420416

421417
/**
422418
* Test constructing SoftButtonObject with an nonempty state list
423419
*/
424420
@Test
425-
public void testConstructingSoftButtonObjectWithNonEmptyStateList() {
421+
public void testConstructSoftButtonObjectWithNonEmptyStateList() {
426422
List<SoftButtonState> stateList = new ArrayList<>();
427423
SoftButtonState softButtonState = new SoftButtonState("general_kenobi", "General Kenobi", null);
428424
stateList.add(softButtonState);
429-
SoftButtonObject softButtonObject2 = new SoftButtonObject("hello_there_again", stateList, "general_kenobi", null);
430-
assertEquals(stateList, softButtonObject2.getStates());
425+
SoftButtonObject softButtonObject = new SoftButtonObject("hello_there", stateList, "general_kenobi", null);
426+
assertEquals(stateList, softButtonObject.getStates());
431427
}
432428

433429
/**
434430
* Test assigning an empty state list to existing SoftButtonObject
435431
*/
436432
@Test
437433
public void testAssignEmptyStateListToSoftButtonObject() {
438-
List<SoftButtonState> stateList = new ArrayList<>();
439-
SoftButtonState softButtonState = new SoftButtonState("object1-state1", "o1s1", null);
434+
List<SoftButtonState> nonEmptyStateList = new ArrayList<>();
435+
List<SoftButtonState> emptyStateList = new ArrayList<>();
436+
SoftButtonState softButtonState = new SoftButtonState("general_kenobi", "General Kenobi", null);
437+
nonEmptyStateList.add(softButtonState);
440438

441-
SoftButtonObject softButtonObject = new SoftButtonObject("hi", softButtonState, null);
439+
SoftButtonObject softButtonObject = new SoftButtonObject("hello_there", nonEmptyStateList, "general_kenobi", null);
442440

443-
softButtonObject.setStates(stateList);
444-
assertNotEquals(stateList, softButtonObject.getStates());
441+
softButtonObject.setStates(emptyStateList);
442+
assertEquals(nonEmptyStateList, softButtonObject.getStates());
445443
}
446444

447445
/**
448446
* Test assigning a nonempty state list to existing SoftButtonObject
449447
*/
450448
@Test
451449
public void testAssignNonEmptyStateListToSoftButtonObject() {
452-
List<SoftButtonState> stateList = new ArrayList<>();
453-
SoftButtonState softButtonState = new SoftButtonState("object1-state1", "o1s1", null);
450+
List<SoftButtonState> stateList1 = new ArrayList<>();
451+
SoftButtonState softButtonState1 = new SoftButtonState("hello_there", "Hello there", null);
452+
stateList1.add(softButtonState1);
454453

455-
SoftButtonObject softButtonObject = new SoftButtonObject("hi", softButtonState, null);
454+
List<SoftButtonState> stateList2 = new ArrayList<>();
455+
SoftButtonState softButtonState2 = new SoftButtonState("general_kenobi", "General Kenobi", null);
456+
stateList2.add(softButtonState2);
456457

457-
stateList.add(softButtonState);
458-
softButtonObject.setStates(stateList);
459-
assertEquals(stateList, softButtonObject.getStates());
458+
SoftButtonObject softButtonObject = new SoftButtonObject("general_kenobi", stateList1, "general_kenobi", null);
459+
460+
softButtonObject.setStates(stateList2);
461+
462+
assertEquals(stateList2, softButtonObject.getStates());
460463
}
461464
}

base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonObject.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@
3232
package com.smartdevicelink.managers.screen;
3333

3434
import androidx.annotation.NonNull;
35-
3635
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
3736
import com.smartdevicelink.proxy.rpc.OnButtonEvent;
3837
import com.smartdevicelink.proxy.rpc.OnButtonPress;
3938
import com.smartdevicelink.proxy.rpc.SoftButton;
4039
import com.smartdevicelink.util.DebugTool;
41-
4240
import java.util.Collections;
4341
import java.util.List;
4442

@@ -406,5 +404,4 @@ public SoftButtonObject clone() {
406404
}
407405
return null;
408406
}
409-
410407
}

0 commit comments

Comments
 (0)