193a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich/*
293a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * Copyright (C) 2010 The Android Open Source Project
393a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich *
493a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * Licensed under the Apache License, Version 2.0 (the "License");
593a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * you may not use this file except in compliance with the License.
693a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * You may obtain a copy of the License at
793a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich *
893a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich *      http://www.apache.org/licenses/LICENSE-2.0
993a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich *
1093a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * Unless required by applicable law or agreed to in writing, software
1193a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * distributed under the License is distributed on an "AS IS" BASIS,
1293a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1393a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * See the License for the specific language governing permissions and
1493a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich * limitations under the License.
1593a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich */
1693a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich
1793a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevichpackage com.android.server;
1893a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich
1993a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevichimport android.content.Context;
2093a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevichimport android.os.FileUtils;
2193a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevichimport android.test.AndroidTestCase;
2293a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich
2393a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevichimport java.io.File;
2493a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich
2593a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich/**
266967cbc959b079fa7e4411360e40e2a0ed65da29Nick Kralevich * Tests for {@link com.android.server.EntropyMixer}
2793a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich */
286967cbc959b079fa7e4411360e40e2a0ed65da29Nick Kralevichpublic class EntropyMixerTest extends AndroidTestCase {
2993a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich
3093a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich    public void testInitialWrite() throws Exception {
3193a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich        File dir = getContext().getDir("testInitialWrite", Context.MODE_PRIVATE);
3293a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich        File file = File.createTempFile("testInitialWrite", "dat", dir);
3393a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich        file.deleteOnExit();
3493a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich        assertEquals(0, FileUtils.readTextFile(file, 0, null).length());
3593a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich
3693a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich        // The constructor has the side effect of writing to file
376ab3d20d3c2de01a342450d83103e9f5e89e670eAlex Klyubin        new EntropyMixer(getContext(), "/dev/null", file.getCanonicalPath(), "/dev/null");
3893a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich
3993a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich        assertTrue(FileUtils.readTextFile(file, 0, null).length() > 0);
4093a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich    }
4193a68398b661c02d6c417a2a04e64a6750a9a119Nick Kralevich}
42