<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.mozstumbler.client;

import android.content.Context;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mozilla.mozstumbler.service.stumblerthread.datahandling.ClientDataStorageManager;
import org.mozilla.mozstumbler.service.stumblerthread.datahandling.DataStorageManager;
import org.mozilla.mozstumbler.svclocator.ServiceLocator;
import org.mozilla.mozstumbler.svclocator.services.ISystemClock;
import org.mozilla.mozstumbler.svclocator.services.MockSystemClock;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static android.test.MoreAsserts.assertNotEqual;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

@Config(emulateSdk = 18)
@RunWith(RobolectricTestRunner.class)
public class QueuedCountsTrackerTest {

    public class StorageTracker implements DataStorageManager.StorageIsEmptyTracker {
        public void notifyStorageStateEmpty(boolean isEmpty) {
        }
    }

    @Test
    public void testNoDataStorageManager() {
        QueuedCountsTracker qct = QueuedCountsTracker.getInstance();

        assertNull(DataStorageManager.getInstance());

        QueuedCountsTracker.QueuedCounts qc = qct.getQueuedCounts();
        assertNotNull(qc);
        assertEquals(0, qc.mBytes);
        assertEquals(0, qc.mCellCount);
        assertEquals(0, qc.mReportCount);
        assertEquals(0, qc.mWifiCount);
    }

    @Test
    public void testCachedValues() {

        Context ctx = Robolectric.application;<commit_msg>force the DataStorageManager to be null<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.mozstumbler.client;

import android.content.Context;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mozilla.mozstumbler.service.stumblerthread.datahandling.ClientDataStorageManager;
import org.mozilla.mozstumbler.service.stumblerthread.datahandling.DataStorageManager;
import org.mozilla.mozstumbler.svclocator.ServiceLocator;
import org.mozilla.mozstumbler.svclocator.services.ISystemClock;
import org.mozilla.mozstumbler.svclocator.services.MockSystemClock;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static android.test.MoreAsserts.assertNotEqual;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

@Config(emulateSdk = 18)
@RunWith(RobolectricTestRunner.class)
public class QueuedCountsTrackerTest {

    public class StorageTracker implements DataStorageManager.StorageIsEmptyTracker {
        public void notifyStorageStateEmpty(boolean isEmpty) {
        }
    }

    @Before
    public void setup() {
        DataStorageManager.sInstance = null;
    }

    @Test
    public void testNoDataStorageManager() {
        QueuedCountsTracker qct = QueuedCountsTracker.getInstance();

        QueuedCountsTracker.QueuedCounts qc = qct.getQueuedCounts();
        assertNotNull(qc);
        assertEquals(0, qc.mBytes);
        assertEquals(0, qc.mCellCount);
        assertEquals(0, qc.mReportCount);
        assertEquals(0, qc.mWifiCount);
    }

    @Test
    public void testCachedValues() {

        Context ctx = Robolectric.application;
{'fraction_non_alphanumeric': 0.08626588465298143, 'fraction_numerical': 0.004887585532746823, 'mean_word_length': 4.561141304347826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '20537', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1194, 'n_words': 255}