blob: f2be109c86026dd51ca65e09cb4ee31e547dbf01 [file] [log] [blame]
Lorenzo Colitti6d553f62016-06-05 02:20:29 +09001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Lorenzo Colitti9997f142016-10-28 12:37:38 +090017package com.android.internal.util.test;
Lorenzo Colitti6d553f62016-06-05 02:20:29 +090018
19import android.content.ContentResolver;
20import android.database.ContentObserver;
21import android.net.Uri;
22import android.provider.Settings;
23import android.test.AndroidTestCase;
24import android.test.mock.MockContentResolver;
25import android.test.mock.MockContext;
26import android.test.suitebuilder.annotation.SmallTest;
Guang Zhu3394a8e2016-06-22 16:30:09 -070027import android.test.suitebuilder.annotation.Suppress;
Lorenzo Colitti6d553f62016-06-05 02:20:29 +090028import android.util.Log;
29
30import java.util.concurrent.CountDownLatch;
31import java.util.concurrent.TimeUnit;
32
33/**
34 * Unit tests for FakeSettingsProvider.
35 */
Lorenzo Colitti6d553f62016-06-05 02:20:29 +090036public class FakeSettingsProviderTest extends AndroidTestCase {
37
38 private MockContentResolver mCr;
39
40 @Override
41 public void setUp() throws Exception {
42 mCr = new MockContentResolver();
43 mCr.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
44 }
45
46 @SmallTest
47 public void testBasicOperation() throws Exception {
48 String settingName = Settings.System.SCREEN_BRIGHTNESS;
49
50 try {
51 Settings.System.getInt(mCr, settingName);
52 fail("FakeSettingsProvider should start off empty.");
53 } catch (Settings.SettingNotFoundException expected) {}
54
55 // Check that fake settings can be written and read back.
56 Settings.System.putInt(mCr, settingName, 123);
57 assertEquals(123, Settings.System.getInt(mCr, settingName));
58 }
59}