Home | History | Annotate | Download | only in deviceowner
      1 /*
      2  * Copyright (C) 2018 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.deviceowner;
     18 
     19 /** Test for user session APIs. */
     20 public class UserSessionTest extends BaseDeviceOwnerTest {
     21 
     22     private static final String START_SESSION_MESSAGE = "Start session";
     23     private static final String END_SESSION_MESSAGE = "End session";
     24 
     25     public void testSetLogoutEnabled() {
     26         mDevicePolicyManager.setLogoutEnabled(getWho(), true);
     27         assertTrue(mDevicePolicyManager.isLogoutEnabled());
     28     }
     29 
     30     public void testSetLogoutDisabled() {
     31         mDevicePolicyManager.setLogoutEnabled(getWho(), false);
     32         assertFalse(mDevicePolicyManager.isLogoutEnabled());
     33     }
     34 
     35     public void testSetStartUserSessionMessage() {
     36         mDevicePolicyManager.setStartUserSessionMessage(getWho(), START_SESSION_MESSAGE);
     37         assertEquals(START_SESSION_MESSAGE,
     38                 mDevicePolicyManager.getStartUserSessionMessage(getWho()));
     39     }
     40 
     41     public void testSetEndUserSessionMessage() {
     42         mDevicePolicyManager.setEndUserSessionMessage(getWho(), END_SESSION_MESSAGE);
     43         assertEquals(END_SESSION_MESSAGE, mDevicePolicyManager.getEndUserSessionMessage(getWho()));
     44     }
     45 
     46     public void testClearStartUserSessionMessage() {
     47         mDevicePolicyManager.setStartUserSessionMessage(getWho(), START_SESSION_MESSAGE);
     48         mDevicePolicyManager.setStartUserSessionMessage(getWho(), null);
     49         assertNull(mDevicePolicyManager.getStartUserSessionMessage(getWho()));
     50     }
     51 
     52 
     53     public void testClearEndUserSessionMessage() {
     54         mDevicePolicyManager.setEndUserSessionMessage(getWho(), END_SESSION_MESSAGE);
     55         mDevicePolicyManager.setEndUserSessionMessage(getWho(), null);
     56         assertNull(mDevicePolicyManager.getEndUserSessionMessage(getWho()));
     57     }
     58 }
     59