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

Commit 1ab26b62 authored by Ilshat Aliyev's avatar Ilshat Aliyev
Browse files

Added prober tests for testing completion, parameters and diagnostics for java files.

The logic of generating ide_query.out will be submitted in a separate change.

Change-Id: I88a0b1430136cca651bee2b1847b1613eda303db
parent f4029eb6
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

java_library {
    name: "ide_query_proberscript_jvm",
    srcs: [
        "Foo.java",
        "Bar.java",
        "other/Other.java",
    ],
}
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright 2014 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.
 */

package jvm;

/** Bar class. The class for testing code assist within the same build module. */
class Bar<K extends Number, V extends Number> {
  Bar() {
    foo(new Foo());
  }

  void foo(Foo f) {}

  void foo(Object o) {}

  void bar(Foo f) {}

  void baz(Object o) {}
}
 No newline at end of file
+94 −7
Original line number Diff line number Diff line
@@ -16,22 +16,109 @@

package jvm;

import java.util.ArrayList;
import java.util.HashSet;
import jvm.other.Other;

/** Foo class. */
public final class Foo {
//               |  | foo_def

  void testParameterInfo() {
    // Test signature help for type parameters.

    Bar<Integer, Double> b = new Bar<>();
    //                               ^ ctor
    //     ^ decl_1
    //              ^ decl_2
    System.out.println(b);

    // step at ctor
    // workspace.waitForReady()
    // paraminfo.trigger()
    // assert paraminfo.items.filter(
    //  label="K extends Number, V extends Number",
    //  selection="K extends Number",
    // )

    // step at decl_1
    // workspace.waitForReady()
    // paraminfo.trigger()
    // assert paraminfo.items.filter(
    //  label="K extends Number, V extends Number",
    //  selection="K extends Number",
    // )

    // step at decl_2
    // workspace.waitForReady()
    // paraminfo.trigger()
    // assert paraminfo.items.filter(
    //  label="K extends Number, V extends Number",
    //  selection="V extends Number",
    // )

    // Test signature help for constructor parameters.

    Other other = new Other(123, "foo");
    //                       ^ param_1
    //                             ^ param_2
    System.out.println(other);

    // step at param_1
    // workspace.waitForReady()
    // paraminfo.trigger()
    // assert paraminfo.items.filter(
    //  label="\\(int first, String second\\)",
    //  selection="int first",
    // )

    // step at param_2
    // workspace.waitForReady()
    // paraminfo.trigger()
    // assert paraminfo.items.empty()
  }

  void testCompletion() {
    ArrayList<Integer> list = new ArrayList<>();
    System.out.println(list);
    Bar<Integer, Double> b = new Bar<>();
    System.out.println(b);

    // ^

    // step
    // ; Test completion on the standard types.
    // type("list.")
    // ; Test completion on types from the same package.
    // workspace.waitForReady()
    // type("b.")
    // completion.trigger()
    // assert completion.items.filter(label="add.*")
    // assert completion.items.filter(label="foo.*")
    // delline()

    Other other = new Other(1, "foo");
    System.out.println(other);

    // ^

    // step
    // ; Test completion on types from a different package.
    // workspace.waitForReady()
    // type("other.")
    // completion.trigger()
    // apply(completion.items.filter(label="other.*").first())
    // type(".")
    // completion.trigger()
    // apply(completion.items.filter(label="other.*").first())
    // delline()
  }

  void testDiagnostics() {

    // ^

    // step
    // ; Test diagnostics about wrong type argument bounds.
    // workspace.waitForReady()
    // type("Bar<String, Double> b;")
    // assert diagnostics.items.filter(
    //  message="type argument .* is not within bounds .*",
    //  code="compiler.err.not.within.bounds",
    // )
    // delline()
  }
}
+4 −0
Original line number Diff line number Diff line

out2X
6build/make/tools/ide_query/prober_scripts/jvm/Foo.javaide_query_proberscript_jvm:
ide_query_proberscript_jvm6build/make/tools/ide_query/prober_scripts/jvm/Foo.java6build/make/tools/ide_query/prober_scripts/jvm/Bar.java>build/make/tools/ide_query/prober_scripts/jvm/other/Other.java
 No newline at end of file
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright 2014 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.
 */

package jvm.other;

/** Other class */
public class Other {
  public Other(int first, String second) {}

  public Other other() {
    return new Other(0, "");
  }
}