Files
packages_apps_Messaging/tests/src/com/android/messaging/datamodel/DataModelTest.java
Taesu Lee 4e99cc0a02 ProcessPendingMessagesAction works based on subscriptions
PorcessPendingMessagesAction queues one message for sending/downloading
associated with a subscription triggering current action at a time. And
the ConnectivityUtil also works based on subscriptions so that pending
messages can be processed regardless of other phones' state in multi-sim
case.

It includes cleanup code as well.

Test: Manual

Change-Id: Id6b4f4a0aa6a3291e7a4d8a5d3f0fbb9db3c5b86
Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
2020-02-28 18:16:54 +09:00

72 lines
2.8 KiB
Java

/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.messaging.datamodel;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.messaging.BugleTestCase;
import com.android.messaging.FakeFactory;
import com.android.messaging.datamodel.data.ConversationData;
import com.android.messaging.datamodel.data.ConversationListData;
import com.android.messaging.datamodel.data.ConversationData.ConversationDataListener;
import com.android.messaging.datamodel.data.ConversationListData.ConversationListDataListener;
import org.mockito.Mock;
public class DataModelTest extends BugleTestCase {
DataModel dataModel;
@Mock protected ConversationDataListener mockConversationDataListener;
@Mock protected ConversationListDataListener mockConversationListDataListener;
@Override
protected void setUp() throws Exception {
super.setUp();
FakeFactory factory = FakeFactory.register(mContext);
dataModel = new DataModelImpl(getTestContext());
factory.withDataModel(dataModel);
}
@SmallTest
public void testCreateConversationList() {
final ConversationListData list = dataModel.createConversationListData(getContext(),
mockConversationListDataListener, true);
assertTrue(list instanceof ConversationListData);
final ConversationData conv = dataModel.createConversationData(getContext(),
mockConversationDataListener, "testConversation");
assertTrue(conv instanceof ConversationData);
}
private static final String FOCUSED_CONV_ID = "focused_conv_id";
@SmallTest
public void testFocusedConversationIsObservable() {
dataModel.setFocusedConversation(FOCUSED_CONV_ID);
assertTrue(dataModel.isNewMessageObservable(FOCUSED_CONV_ID));
dataModel.setFocusedConversation(null);
assertFalse(dataModel.isNewMessageObservable(FOCUSED_CONV_ID));
}
@SmallTest
public void testConversationIsObservableInList() {
dataModel.setConversationListScrolledToNewestConversation(true);
assertTrue(dataModel.isNewMessageObservable(FOCUSED_CONV_ID));
dataModel.setConversationListScrolledToNewestConversation(false);
assertFalse(dataModel.isNewMessageObservable(FOCUSED_CONV_ID));
}
}