1 /* 2 * Copyright (C) 2021 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.ons; 18 19 import android.content.Context; 20 import android.content.Intent; 21 22 import org.junit.Before; 23 import org.junit.Test; 24 import org.mockito.Mock; 25 26 public class ONSProfileResultReceiverTest extends ONSBaseTest { 27 28 @Mock 29 Context mMockContext; 30 31 @Before setUp()32 public void setUp() throws Exception { 33 super.setUp("ONSTest"); 34 } 35 36 @Test testONSResultReceiverWithNoActionString()37 public void testONSResultReceiverWithNoActionString() { 38 ONSProfileResultReceiver onsReceiver = new ONSProfileResultReceiver(); 39 40 //Empty Intent with all null fields. 41 Intent intent = new Intent(); 42 43 try { 44 onsReceiver.onReceive(mMockContext, intent); 45 } catch (Exception e) { 46 fail("Exception should not be thrown"); 47 } 48 49 } 50 51 @Test testONSResultReceiverWithActionStringNullExtras()52 public void testONSResultReceiverWithActionStringNullExtras() { 53 ONSProfileResultReceiver onsReceiver = new ONSProfileResultReceiver(); 54 55 //Intent with action String but all null extras. 56 Intent intent = new Intent(); 57 intent.setAction("com.android.ons.TEST_ACTION"); 58 59 try { 60 onsReceiver.onReceive(mContext, intent); 61 } catch (Exception e) { 62 fail("Exception should not be thrown"); 63 } 64 65 } 66 } 67