zoukankan      html  css  js  c++  java
  • 单元测试之寻找bug

    首先,打开老师给的代码

    JAVA程序:

    package com.example.tasks;

    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.provider.ContactsContract;
    import android.widget.Toast;

    import com.avos.avoscloud.AVException;
    import com.avos.avoscloud.AVObject;
    import com.avos.avoscloud.AVQuery;
    import com.avos.avoscloud.AVUser;
    import com.avos.avoscloud.FindCallback;

    import java.util.List;

    /**
     * Created by ywq on 2016/6/2.
     */
    public class AlarmActivity extends Activity {


        MediaPlayer alarmMusic;
        String note;
        String id;


        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_tixing);


             id = getIntent().getExtras().getString("id");


    //        Toast.makeText(this,id,Toast.LENGTH_LONG).show();


            final AVQuery<AVObject> query = new AVQuery<>("NoteList");
            query.whereEqualTo("objectId", id);
            query.findInBackground(new FindCallback<AVObject>() {
                @Override
                public void done(List<AVObject> list, AVException e) {

                    for (AVObject avobect : list) {
                        note = avobect.getString("note");
                    }

    //                note = list.get(0).getString("note");


                    // 加载指定音乐,并为之创建MediaPlayer对象
                    alarmMusic = MediaPlayer.create(AlarmActivity.this, R.raw.ls3);
                    alarmMusic.setLooping(true);
                    // 播放音乐
                    alarmMusic.start();
                    // 创建一个对话框

                    new AlertDialog.Builder(AlarmActivity.this)
                            .setTitle("提醒")
                            .setMessage(note)

                            .setPositiveButton(
                                    "确定",
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            // 停止音乐
                                            alarmMusic.stop();
                                            // 结束该Activity
                                            finish();
                                        }
                                    }
                            )
                            .show();

                }
            });

        }

    }

    activity 程序:

       <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="vertical">


            <EditText
                android:id="@+id/LoginName"
                android:layout_width="match_parent"
                android:layout_height="40dp"

                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:background="@android:color/transparent"
                android:hint="请输入用户名"
                android:inputType="text"
                 />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:background="#000000" />

            <EditText
                android:id="@+id/LoginPwd"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"

                android:background="@android:color/transparent"
                android:hint="请输入密码"
                android:inputType="textPassword"
                 />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:background="#000000"/>

            <Button
                android:id="@+id/Login"
                android:layout_width="100dp"
                android:layout_height="40dp"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="20dp"
                android:background="#FFC125"
                android:text="登录"
                android:textColor="#ffffff"
                android:textSize="20sp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:gravity="center_horizontal"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:text="没有账号?" />

                <TextView
                    android:id="@+id/Regist1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:text="马上注册"
                    android:textColor="@android:color/holo_blue_bright" />
            </LinearLayout>
        </LinearLayout>

    </LinearLayout>

    结果:

  • 相关阅读:
    PPK提供的浏览器类型及版本检测方法
    从KPI到OKR,高阶产品人如何推动业务高速增长
    线上流量越发昂贵,如何通过裂变营销实现业务增长?
    快速了解云原生架构
    阿里巴巴超大规模中台型团队研发提效实践
    如何通过数据智能玩转私域流量新生态
    Serverless Kubernetes:理想,现实与未来
    这只猫在云端定居了?边缘计算在天猫精灵云应用上的落地实践
    阿里毕玄:提升代码能力的4段经历
    你女朋友在买买买时,程序员小哥在干嘛?
  • 原文地址:https://www.cnblogs.com/lx1502720102/p/6637949.html
Copyright © 2011-2022 走看看