Skip to content

Commit

Permalink
//fbandroid/libraries/textlayoutbuilder/library/src/test/java/com/fac…
Browse files Browse the repository at this point in the history
…ebook/fbui/textlayoutbuilder/shadows:shadows

Differential Revision: D64034471

fbshipit-source-id: 29027659c3141e2d34bfe295a6903c50db29c5d2
  • Loading branch information
generatedunixname89002005287564 authored and facebook-github-bot committed Oct 8, 2024
1 parent 52bbff6 commit d23bb7f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 60 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* 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.facebook.fbui.textlayoutbuilder.shadows

import android.text.Layout
import android.text.TextPaint
import org.robolectric.annotation.Implementation
import org.robolectric.annotation.Implements

@Implements(Layout::class)
object ShadowLayout {

const val LONG_TEXT: String = "ZzZzZzZzZzZzZzZzZzZzZz"
const val SHORT_TEXT: String = "Z"
const val LONG_TEXT_LENGTH: Int = 100
const val SHORT_TEXT_LENGTH: Int = 5

@JvmStatic
@Implementation
fun getDesiredWidth(source: CharSequence, paint: TextPaint?): Float {
if (LONG_TEXT == source) {
return LONG_TEXT_LENGTH.toFloat()
} else if (SHORT_TEXT == source) {
return SHORT_TEXT_LENGTH.toFloat()
}
return 0f
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,35 @@
* limitations under the License.
*/

package com.facebook.fbui.textlayoutbuilder.shadows;
package com.facebook.fbui.textlayoutbuilder.shadows

import android.graphics.Canvas;
import android.graphics.Picture;
import com.facebook.infer.annotation.Nullsafe;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import android.graphics.Canvas
import android.graphics.Picture
import org.robolectric.annotation.Implementation
import org.robolectric.annotation.Implements

@Nullsafe(Nullsafe.Mode.LOCAL)
@Implements(Picture.class)
public class ShadowPicture {
@Implements(Picture::class)
class ShadowPicture {

@Implementation
public void __constructor__(int nativePicture, boolean fromStream) {
fun __constructor__(nativePicture: Int, fromStream: Boolean) {
// Do nothing.
}

@Implementation
public void __constructor__(int nativePicture) {
fun __constructor__(nativePicture: Int) {
// Do nothing.
}

@Implementation
public void __constructor__(long nativePicture) {
fun __constructor__(nativePicture: Long) {
// Do nothing.
}

@Implementation
public void __constructor__() {
fun __constructor__() {
// Do nothing.
}

@Implementation
public Canvas beginRecording(int width, int height) {
return new Canvas();
}
@Implementation fun beginRecording(width: Int, height: Int): Canvas = Canvas()
}

0 comments on commit d23bb7f

Please sign in to comment.