我想在活动调用onCreate()和onResume()时测试键盘可见性.
如何测试键盘是否显示使用浓缩咖啡?
我似乎无法在新控制台中找到会话长度配置.也找不到任何关于它的文献或会话管理.
如果我的firebase引用中存储了50,000个项目的列表,并且自上次客户端在线和侦听以来已经将5个项目添加到该列表中,那么我必须使用哪个回调才会触发5已添加的新项目?
我在我的客户端启用了离线持久性Firebase.getDefaultConfig().setPersistenceEnabled(true);.我有一个监听器绑定到一个活动,听取孩子们添加到参考.每次onChildAdded为参考中的所有数据调用创建活动.是否有可能只为我的本地缓存和firebase服务器上的数据之间的"diff"进行调用onChildAdded和onChildRemoved调用?或者,如果那不可能,那么在onChild*firebase的最新更新之后只触发那些回调?
我正在开发我的第一个Android应用程序,我正在设置CI服务器.我的espresso咖啡测试在我的机器上正常运行,但travis错误出现以下情况
java.lang.RuntimeException:等待视图层次结构的根目录具有窗口焦点,而不是请求布局超过10秒.
在运行测试之前,我似乎需要解锁仿真器屏幕.为此,我必须src/debug使用所需权限添加清单,然后使用以下命令解锁屏幕:
KeyguardManager mKeyGuardManager = (KeyguardManager) ctx.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock mLock = mKeyGuardManager.newKeyguardLock(name);
mLock.disableKeyguard();
Run Code Online (Sandbox Code Playgroud)
问题是我不想乱丢我的活动,上面的代码包含在if块中.有没有办法从浓缩咖啡测试中解锁屏幕?
我的浓咖啡测试:
@RunWith(AndroidJUnit4.class)
public class EspressoSetupTest {
@Rule
public final ActivityTestRule<WelcomeActivity> activity =
new ActivityTestRule<>(WelcomeActivity.class, true, true);
@Test
public void launchTest() {
onView(withId(R.id.welcome_textView_hello))
.perform(click())
.check(matches(withText("RetroLambda is working")));
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Google登录工作流程来获取GoogleSignInAccount对象.我想验证谷歌用户到我的firebase应用程序,这需要一个令牌,可以在构建我的谷歌客户端API时使用requestIdToken(String serverClientId)请求.我不确定要把什么作为我的serverClientId?
我正在为我的实体使用autovalue并注释它们以允许json解析.
有新的SDK新的注解:Exclude,IgnoreExtraProperties,ThrowOnExtraProperties和@PropertyName:https://firebase.google.com/docs/reference/android/com/google/firebase/database/PropertyName.但是,sdk似乎缺少PropertyName ..
使用DataSnapshot.getValue()时,是否可以以Json格式获取JsonObjects或字符串?也许我的搜索不够彻底,但我找不到使用自定义序列化程序的方法.
我在使用mockito在我的android应用程序中测试我的presenter类时遇到了一些奇怪的行为.
即使它通过我的设备,我的测试也会失败.行为不端的代码:
@Test
public void testValidPhoneNumber() throws Exception {
String phone = "0123456789";
assert(TextUtils.isDigitsOnly(phone));
}
Run Code Online (Sandbox Code Playgroud)
以上错误导致以下错误:
java.lang.AssertionError
at com.usehomeroom.vasuki.auth.RegisterPresenterTest.testValidPhoneNumber(RegisterPresenterTest.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Process finished with exit code 255
Run Code Online (Sandbox Code Playgroud) 我试图使用约束布局链垂直居中两个文本视图.我知道我可以将文本布局包装成线性布局,但我想尝试新的链特征.当我构建我的项目时,虽然我收到错误,Error:(28, 50) No resource found that matches the given name (at 'layout_constraintBottom_toTopOf' with value '@id/item_school_location').
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="72dp">
<ImageView
android:id="@+id/item_school_logo"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:contentDescription="@string/item_school_logo_description"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
<TextView
android:id="@+id/item_school_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="72dp"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Light.SearchResult.Subtitle"
app:layout_constraintBottom_toTopOf="@id/item_school_location"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5"
app:layout_constraintVertical_chainPacked="true" />
<TextView
android:id="@+id/item_school_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="72dp"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/item_school_name" />
</android.support.constraint.ConstraintLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)
有谁知道是什么导致了这个错误?