use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class Tab method swapWebContents.
/** This is currently called when committing a pre-rendered page. */
@VisibleForTesting
@CalledByNative
public void swapWebContents(WebContents webContents, boolean didStartLoad, boolean didFinishLoad) {
ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext, PRODUCT_VERSION);
ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc);
cv.setContentDescription(mThemedApplicationContext.getResources().getString(R.string.accessibility_content_view));
cvc.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, webContents, getWindowAndroid());
swapContentViewCore(cvc, false, didStartLoad, didFinishLoad);
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class AbstractMediaRouteController method setPlayerStateForMediaItemState.
@VisibleForTesting
void setPlayerStateForMediaItemState(int state) {
PlayerState playerState = PlayerState.STOPPED;
switch(state) {
case MediaItemStatus.PLAYBACK_STATE_BUFFERING:
playerState = PlayerState.LOADING;
break;
case MediaItemStatus.PLAYBACK_STATE_CANCELED:
playerState = PlayerState.FINISHED;
break;
case MediaItemStatus.PLAYBACK_STATE_ERROR:
playerState = PlayerState.ERROR;
break;
case MediaItemStatus.PLAYBACK_STATE_FINISHED:
playerState = PlayerState.FINISHED;
break;
case MediaItemStatus.PLAYBACK_STATE_INVALIDATED:
playerState = PlayerState.INVALIDATED;
break;
case MediaItemStatus.PLAYBACK_STATE_PAUSED:
if (isAtEndOfVideo(getPosition(), getDuration())) {
playerState = PlayerState.FINISHED;
} else {
playerState = PlayerState.PAUSED;
}
break;
case MediaItemStatus.PLAYBACK_STATE_PENDING:
playerState = PlayerState.PAUSED;
break;
case MediaItemStatus.PLAYBACK_STATE_PLAYING:
playerState = PlayerState.PLAYING;
break;
default:
break;
}
mRemotePlayerState = playerState;
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class DelayedInvalidationsController method addPendingInvalidation.
/**
* Stores preferences to indicate that an invalidation has arrived, but dropped on the floor.
*/
@VisibleForTesting
void addPendingInvalidation(Context context, String account, PendingInvalidation invalidation) {
SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
String oldAccount = prefs.getString(DELAYED_ACCOUNT_NAME, null);
// Make sure to construct a new set so it can be modified safely. See crbug.com/568369.
Set<String> invals = new HashSet<String>(prefs.getStringSet(DELAYED_INVALIDATIONS, new HashSet<String>(1)));
assert invals.isEmpty() || oldAccount != null;
if (oldAccount != null && !oldAccount.equals(account)) {
invals.clear();
}
SharedPreferences.Editor editor = prefs.edit();
editor.putString(DELAYED_ACCOUNT_NAME, account);
if (invalidation.mObjectSource == 0 || (oldAccount != null && invals.isEmpty())) {
editor.putStringSet(DELAYED_INVALIDATIONS, null);
} else {
invals.add(invalidation.encodeToString());
editor.putStringSet(DELAYED_INVALIDATIONS, invals);
}
editor.apply();
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class CastMessageHandler method buildInternalMessage.
@VisibleForTesting
String buildInternalMessage(String type, String message, String clientId, int sequenceNumber) {
JSONObject json = new JSONObject();
try {
json.put("type", type);
json.put("sequenceNumber", sequenceNumber);
json.put("timeoutMillis", 0);
json.put("clientId", clientId);
// messages.
if (message == null || "remove_session".equals(type) || "disconnect_session".equals(type)) {
json.put("message", message);
} else {
JSONObject jsonMessage = new JSONObject(message);
if ("v2_message".equals(type) && "MEDIA_STATUS".equals(jsonMessage.getString("type"))) {
sanitizeMediaStatusMessage(jsonMessage);
}
json.put("message", jsonMessage);
}
} catch (JSONException e) {
Log.e(TAG, "Failed to build the reply: " + e);
}
return json.toString();
}
use of org.chromium.base.VisibleForTesting in project AndroidChromium by JackyAndroid.
the class CastMessageHandler method handleAppMessage.
// An example of the Cast application message:
// {
// "type":"app_message",
// "message": {
// "sessionId":"...",
// "namespaceName":"...",
// "message": ...
// },
// "sequenceNumber":0,
// "timeoutMillis":3000,
// "clientId":"14417311915272175"
// }
@VisibleForTesting
boolean handleAppMessage(JSONObject jsonMessage) throws JSONException {
assert "app_message".equals(jsonMessage.getString("type"));
String clientId = jsonMessage.getString("clientId");
if (clientId == null || !mRouteProvider.getClients().contains(clientId))
return false;
JSONObject jsonAppMessageWrapper = jsonMessage.getJSONObject("message");
if (!mSession.getSessionId().equals(jsonAppMessageWrapper.getString("sessionId"))) {
return false;
}
String namespaceName = jsonAppMessageWrapper.getString("namespaceName");
if (namespaceName == null || namespaceName.isEmpty())
return false;
if (!mSession.getNamespaces().contains(namespaceName))
return false;
int sequenceNumber = jsonMessage.optInt("sequenceNumber", INVALID_SEQUENCE_NUMBER);
Object actualMessageObject = jsonAppMessageWrapper.get("message");
if (actualMessageObject == null)
return false;
if (actualMessageObject instanceof String) {
String actualMessage = jsonAppMessageWrapper.getString("message");
return mSession.sendStringCastMessage(actualMessage, namespaceName, clientId, sequenceNumber);
}
JSONObject actualMessage = jsonAppMessageWrapper.getJSONObject("message");
return sendJsonCastMessage(actualMessage, namespaceName, clientId, sequenceNumber);
}
Aggregations