### Question:
DbViewerTask extends AsyncTask<Void, Integer, Void> { @Override protected void onPreExecute() { super.onPreExecute(); if (dbViewerFragment.databaseViewerActivity.getAppTheme().equals(AppTheme.DARK) || dbViewerFragment.databaseViewerActivity.getAppTheme().equals(AppTheme.BLACK)) { htmlInit = "<html><body><table border='1' style='width:100%;color:#ffffff'>"; } else { htmlInit = "<html><body><table border='1' style='width:100%;color:#000000'>"; } stringBuilder.append(htmlInit); dbViewerFragment.loadingText.setVisibility(View.VISIBLE); } DbViewerTask(
      Cursor schemaCursor,
      Cursor contentCursor,
      WebView webView,
      DbViewerFragment dbViewerFragment);   }### Answer:
@Test public void testOnPreExecute() { DbViewerFragment mock = mock(DbViewerFragment.class); TextView loadingText = new TextView(ApplicationProvider.getApplicationContext()); mock.loadingText = loadingText; mock.databaseViewerActivity = mock(DatabaseViewerActivity.class); mock.loadingText.setVisibility(View.GONE); when(mock.databaseViewerActivity.getAppTheme()).thenReturn(AppTheme.DARK); DbViewerTask task = new DbViewerTask(null, null, webView, mock); task.onPreExecute(); assertEquals(VISIBLE, mock.loadingText.getVisibility()); assertTrue(task.htmlInit.contains("color:#ffffff")); assertEquals("utf-8", webView.getSettings().getDefaultTextEncodingName()); when(mock.databaseViewerActivity.getAppTheme()).thenReturn(AppTheme.BLACK); task = new DbViewerTask(null, null, webView, mock); task.onPreExecute(); assertEquals(VISIBLE, mock.loadingText.getVisibility()); assertTrue(task.htmlInit.contains("color:#ffffff")); assertEquals("utf-8", webView.getSettings().getDefaultTextEncodingName()); when(mock.databaseViewerActivity.getAppTheme()).thenReturn(AppTheme.LIGHT); task = new DbViewerTask(null, null, webView, mock); task.onPreExecute(); assertEquals(VISIBLE, mock.loadingText.getVisibility()); assertTrue(task.htmlInit.contains("color:#000000")); assertEquals("utf-8", webView.getSettings().getDefaultTextEncodingName()); }