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)));

        }

    }

  • 相关阅读:
    网络世界中的图片以及相关的处理
    Ninject 2.x细说1.基本使用
    Orchard1.4新功能自动路由(AutoRouter)并附Orchard最新1.4版汉化包
    json的一点总结
    ASP.NET MVC路由扩展:路由映射
    厚积薄发,丰富的公用类库积累,助你高效进行系统开发(12) 网络相关操作辅助类
    IIS是如何处理ASP.NET请求的
    一周最新示例代码回顾 (3/19–3/25)
    .NET插件系统(三) 插件间通信问题——设计可自组织和注入的组装程序
    缓存总结
  • 原文地址:https://www.cnblogs.com/32zmx/p/6560194.html
Copyright © 2011-2022 走看看