zoukankan      html  css  js  c++  java
  • MainTest

    '界面设计'

    ………

      <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="Hello Word"

            android:id="@+id/textView"

            android:textSize="20dp"/>

        <EditText

            android:hint="Enter your name here"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:id="@+id/editText"

            android:textSize="20dp"

            android:layout_below="@+id/textView"

            android:layout_alignParentRight="true"

            android:layout_alignParentEnd="true" />

        <Button

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="Say Hello"

            android:id="@+id^tton"

            android:textSize="50dp"

            android:layout_marginTop="67dp"

            android:layout_below="@+id/editText"

            android:layout_alignParentRight="true"

            android:layout_alignParentEnd="true" />

    ………

    '界面代码'

    ………

    import android.support.v7.app.AppCompatActivity;

    import android.os.Bundle;

    import android.view.View;

    import android.widget.Button;

    import android.widget.EditText;

    import android.widget.TextView;

    public class MainActivity extends AppCompatActivity {

        private TextView textView;

        private EditText editText;

        private Button button;

        @Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.activity_main);textView= (TextView) findViewById(R.id.textView);

            editText= (EditText) findViewById(R.id.editText);

            button= (Button) findViewById(R.id.button);

            button.setOnClickListener(new View.OnClickListener() {

                @Override

                public void onClick(View view) {

                    editText.setText(textView.getText().toString());

                }

            });

        }

    ………

    '代码测试'

    ………

    package com.example.administrator.main;

    import android.app.Activity;

    import android.test.ActivityTestCase;

    import junit.framework.TestCase;

    import java.text.RuleBasedCollator;

    /**

     * Created by Administrator on 2017/3/16

     */

    public class MainActivityTest extends TestCase {

    private static final String STRING_TO_BE_TYPED="Peter";

        public ActivityTestCaseRule<MainActivity> mainActivityRule=new ActivityTestRule<>(MainActivity);

        public void sayhello() {

       onView(withId(R.id.editText)).perform(typeText(STRING_TO_BE_TYPED)).closeSoftKeyboard;

               String expectedText="Hello,"+STRING_TO_BE_TYPED+"!";

            onView(withId(R.Id.textView)).check(matches(withText(expectedText)));

        }

    }

  • 相关阅读:
    [置顶] win7 && win8 下安装SqlServer 2008出现错误无法将对象实例化的问题
    [置顶] sizeof()和c++中变量们
    [置顶] sql2008 附加数据库 .mdf 出现错误 解决方案
    [置顶] 漂亮的 tab 样式
    [置顶] 认识指针和指针变量
    [置顶] SqlHelper类
    [置顶] 第一次使用事物 利用线性表
    [置顶] 设计模式之单例模式 (Design patterns of the The singleton pattern)c#
    [置顶] ListBox控件的数据绑定
    RedHat 6.0(64位)如何使用CentOS YUM源更新的方法
  • 原文地址:https://www.cnblogs.com/32zmx/p/6560194.html
Copyright © 2011-2022 走看看