Browse Source

Fix tests and compilation error after removing screenBackgroundColor

Guy Carmeli 6 years ago
parent
commit
ef557cf540

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java View File

@@ -37,8 +37,8 @@ public class OptionsPresenter {
37 37
     }
38 38
 
39 39
     private void applyViewOptions(View view, Options options) {
40
-        if (options.screenBackgroundColor.hasValue()) {
41
-            view.setBackgroundColor(options.screenBackgroundColor.get());
40
+        if (options.layout.backgroundColor.hasValue()) {
41
+            view.setBackgroundColor(options.layout.backgroundColor.get());
42 42
         }
43 43
     }
44 44
 

+ 11
- 5
lib/android/app/src/test/java/com/reactnativenavigation/parse/OptionsTest.java View File

@@ -67,11 +67,13 @@ public class OptionsTest extends BaseTest {
67 67
 
68 68
     @Test
69 69
     public void parsesJson() throws Exception {
70
+        JSONObject layout = new JSONObject()
71
+                .put("backgroundColor", SCREEN_BACKGROUND_COLOR);
70 72
         JSONObject json = new JSONObject()
71 73
                 .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
72 74
                 .put("fab", createFab())
73 75
                 .put("bottomTabs", createBottomTabs())
74
-                .put("screenBackgroundColor",SCREEN_BACKGROUND_COLOR);
76
+                .put("layout", layout);
75 77
         Options result = Options.parse(mockLoader, json);
76 78
         assertResult(result);
77 79
     }
@@ -99,7 +101,7 @@ public class OptionsTest extends BaseTest {
99 101
         assertThat(result.fabOptions.hideOnScroll.get()).isEqualTo(FAB_HIDE_ON_SCROLL);
100 102
         assertThat(result.fabOptions.alignVertically.get()).isEqualTo(FAB_ALIGN_VERTICALLY);
101 103
         assertThat(result.fabOptions.alignHorizontally.get()).isEqualTo(FAB_ALIGN_HORIZONTALLY);
102
-        assertThat(result.screenBackgroundColor.get()).isEqualTo(SCREEN_BACKGROUND_COLOR);
104
+        assertThat(result.layout.backgroundColor.get()).isEqualTo(SCREEN_BACKGROUND_COLOR);
103 105
     }
104 106
 
105 107
     @NonNull
@@ -209,11 +211,13 @@ public class OptionsTest extends BaseTest {
209 211
 
210 212
     @Test
211 213
     public void mergeDefaultOptions() throws Exception {
214
+        JSONObject layout = new JSONObject()
215
+                .put("backgroundColor", SCREEN_BACKGROUND_COLOR);
212 216
         JSONObject json = new JSONObject()
213 217
                 .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
214 218
                 .put("fab", createFab())
215 219
                 .put("bottomTabs", createBottomTabs())
216
-                .put("screenBackgroundColor",SCREEN_BACKGROUND_COLOR);
220
+                .put("layout", layout);
217 221
         Options defaultOptions = Options.parse(mockLoader, json);
218 222
         Options options = new Options();
219 223
 
@@ -222,11 +226,13 @@ public class OptionsTest extends BaseTest {
222 226
 
223 227
     @Test
224 228
     public void mergedDefaultOptionsDontOverrideGivenOptions() throws Exception {
229
+        JSONObject layout = new JSONObject()
230
+                .put("backgroundColor", SCREEN_BACKGROUND_COLOR);
225 231
         JSONObject defaultJson = new JSONObject()
226 232
                 .put("topBar", createOtherTopBar())
227 233
                 .put("fab", createOtherFab())
228 234
                 .put("bottomTabs", createOtherBottomTabs())
229
-                .put("screenBackgroundColor",SCREEN_BACKGROUND_COLOR);
235
+                .put("layout", layout);
230 236
         Options defaultOptions = Options.parse(mockLoader, defaultJson);
231 237
 
232 238
         JSONObject json = new JSONObject()
@@ -241,7 +247,7 @@ public class OptionsTest extends BaseTest {
241 247
     public void defaultEmptyOptions() {
242 248
         Options uut = new Options();
243 249
         assertThat(uut.topBar.title.text.get("")).isEmpty();
244
-        assertThat(uut.screenBackgroundColor.hasValue()).isFalse();
250
+        assertThat(uut.layout.backgroundColor.hasValue()).isFalse();
245 251
 
246 252
     }
247 253