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
     }
37
     }
38
 
38
 
39
     private void applyViewOptions(View view, Options options) {
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
 
67
 
68
     @Test
68
     @Test
69
     public void parsesJson() throws Exception {
69
     public void parsesJson() throws Exception {
70
+        JSONObject layout = new JSONObject()
71
+                .put("backgroundColor", SCREEN_BACKGROUND_COLOR);
70
         JSONObject json = new JSONObject()
72
         JSONObject json = new JSONObject()
71
                 .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
73
                 .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
72
                 .put("fab", createFab())
74
                 .put("fab", createFab())
73
                 .put("bottomTabs", createBottomTabs())
75
                 .put("bottomTabs", createBottomTabs())
74
-                .put("screenBackgroundColor",SCREEN_BACKGROUND_COLOR);
76
+                .put("layout", layout);
75
         Options result = Options.parse(mockLoader, json);
77
         Options result = Options.parse(mockLoader, json);
76
         assertResult(result);
78
         assertResult(result);
77
     }
79
     }
99
         assertThat(result.fabOptions.hideOnScroll.get()).isEqualTo(FAB_HIDE_ON_SCROLL);
101
         assertThat(result.fabOptions.hideOnScroll.get()).isEqualTo(FAB_HIDE_ON_SCROLL);
100
         assertThat(result.fabOptions.alignVertically.get()).isEqualTo(FAB_ALIGN_VERTICALLY);
102
         assertThat(result.fabOptions.alignVertically.get()).isEqualTo(FAB_ALIGN_VERTICALLY);
101
         assertThat(result.fabOptions.alignHorizontally.get()).isEqualTo(FAB_ALIGN_HORIZONTALLY);
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
     @NonNull
107
     @NonNull
209
 
211
 
210
     @Test
212
     @Test
211
     public void mergeDefaultOptions() throws Exception {
213
     public void mergeDefaultOptions() throws Exception {
214
+        JSONObject layout = new JSONObject()
215
+                .put("backgroundColor", SCREEN_BACKGROUND_COLOR);
212
         JSONObject json = new JSONObject()
216
         JSONObject json = new JSONObject()
213
                 .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
217
                 .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
214
                 .put("fab", createFab())
218
                 .put("fab", createFab())
215
                 .put("bottomTabs", createBottomTabs())
219
                 .put("bottomTabs", createBottomTabs())
216
-                .put("screenBackgroundColor",SCREEN_BACKGROUND_COLOR);
220
+                .put("layout", layout);
217
         Options defaultOptions = Options.parse(mockLoader, json);
221
         Options defaultOptions = Options.parse(mockLoader, json);
218
         Options options = new Options();
222
         Options options = new Options();
219
 
223
 
222
 
226
 
223
     @Test
227
     @Test
224
     public void mergedDefaultOptionsDontOverrideGivenOptions() throws Exception {
228
     public void mergedDefaultOptionsDontOverrideGivenOptions() throws Exception {
229
+        JSONObject layout = new JSONObject()
230
+                .put("backgroundColor", SCREEN_BACKGROUND_COLOR);
225
         JSONObject defaultJson = new JSONObject()
231
         JSONObject defaultJson = new JSONObject()
226
                 .put("topBar", createOtherTopBar())
232
                 .put("topBar", createOtherTopBar())
227
                 .put("fab", createOtherFab())
233
                 .put("fab", createOtherFab())
228
                 .put("bottomTabs", createOtherBottomTabs())
234
                 .put("bottomTabs", createOtherBottomTabs())
229
-                .put("screenBackgroundColor",SCREEN_BACKGROUND_COLOR);
235
+                .put("layout", layout);
230
         Options defaultOptions = Options.parse(mockLoader, defaultJson);
236
         Options defaultOptions = Options.parse(mockLoader, defaultJson);
231
 
237
 
232
         JSONObject json = new JSONObject()
238
         JSONObject json = new JSONObject()
241
     public void defaultEmptyOptions() {
247
     public void defaultEmptyOptions() {
242
         Options uut = new Options();
248
         Options uut = new Options();
243
         assertThat(uut.topBar.title.text.get("")).isEmpty();
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