Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cf63e57 authored by Maksymilian Osowski's avatar Maksymilian Osowski Committed by Android (Google) Code Review
Browse files

Merge "Added "run all tests in the current directory" menu option."

parents 9cefc648 ff314d70
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/run_all"
          android:title="@string/run_all_tests" />
</menu>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -25,4 +25,6 @@ limitations under the License.
    <string name="dialog_progress_msg">Please wait...</string>

    <string name="runner_preloading_title">Preloading tests...</string>

    <string name="run_all_tests">Run all tests in the current directory</string>
</resources>
 No newline at end of file
+31 −12
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
@@ -205,11 +208,7 @@ public class DirListActivity extends ListActivity {
                    showDir(item.getRelativePath());
                } else {
                    /** Run the test */
                    Intent intent = new Intent();
                    intent.setClass(DirListActivity.this, TestsListActivity.class);
                    intent.setAction(Intent.ACTION_RUN);
                    intent.putExtra(TestsListActivity.EXTRA_TEST_PATH, item.getRelativePath());
                    startActivity(intent);
                    runAllTestsUnder(item.getRelativePath());
                }
            }
        });
@@ -236,6 +235,32 @@ public class DirListActivity extends ListActivity {
        showDir("");
    }

    private void runAllTestsUnder(String relativePath) {
        Intent intent = new Intent();
        intent.setClass(DirListActivity.this, TestsListActivity.class);
        intent.setAction(Intent.ACTION_RUN);
        intent.putExtra(TestsListActivity.EXTRA_TEST_PATH, relativePath);
        startActivity(intent);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.gui_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.run_all:
                runAllTestsUnder(mCurrentDirPath);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @Override
    /**
     * Moves to the parent directory if one exists. Does not allow to move above
@@ -278,13 +303,7 @@ public class DirListActivity extends ListActivity {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        removeDialog(DIALOG_RUN_ABORT_DIR);
                        /** Run the tests */
                        Intent intent = new Intent();
                        intent.setClass(DirListActivity.this, TestsListActivity.class);
                        intent.setAction(Intent.ACTION_RUN);
                        intent.putExtra(TestsListActivity.EXTRA_TEST_PATH,
                                args.getString("relativePath"));
                        startActivity(intent);
                        runAllTestsUnder(args.getString("relativePath"));
                    }
                });