
com.facebook.testing.screenshot.plugin.TextViewDumper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Screenshot Tests for Android
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.testing.screenshot.plugin;
import java.util.Map;
import android.view.View;
import android.widget.TextView;
/**
* Dumps useful details from a TextView
*/
public class TextViewDumper implements ViewDumpPlugin {
@Override
public void dump(View view, Map output) {
if (!(view instanceof TextView)) {
return;
}
TextView tv = (TextView) view;
CharSequence text;
try {
text = tv.getText();
} catch (RuntimeException e) {
// Somebody has a custom TextView that misbehaves
text = "unsupported";
}
if (text == null) {
text = "null";
}
output.put("text", text.toString());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy