Home | History | Annotate | Download | only in appwithdata
      1 /*
      2  * Copyright (C) 2009 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 
     17 package com.android.cts.appwithdata;
     18 
     19 import java.io.FileOutputStream;
     20 import java.io.IOException;
     21 
     22 import android.content.Context;
     23 import android.test.AndroidTestCase;
     24 
     25 /**
     26  * Test that will create private app data.
     27  *
     28  * This is not really a test per-say. Its just used as a hook so the test controller can trigger
     29  * the creation of private app data.
     30  */
     31 public class CreatePrivateDataTest extends AndroidTestCase {
     32 
     33     /**
     34      * Name of private file to create.
     35      */
     36     private static final String PRIVATE_FILE_NAME = "private_file.txt";
     37 
     38     /**
     39      * Creates a file private to this app
     40      * @throws IOException if any error occurred when creating the file
     41      */
     42     public void testCreatePrivateData() throws IOException {
     43         FileOutputStream outputStream = getContext().openFileOutput(PRIVATE_FILE_NAME,
     44                 Context.MODE_PRIVATE);
     45         outputStream.write("file contents".getBytes());
     46         outputStream.close();
     47     }
     48 }
     49