Home | History | Annotate | Download | only in findUsages
      1 /*
      2  * Copyright 2015, Google Inc.
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions are
      7  * met:
      8  *
      9  *     * Redistributions of source code must retain the above copyright
     10  * notice, this list of conditions and the following disclaimer.
     11  *     * Redistributions in binary form must reproduce the above
     12  * copyright notice, this list of conditions and the following disclaimer
     13  * in the documentation and/or other materials provided with the
     14  * distribution.
     15  *     * Neither the name of Google Inc. nor the names of its
     16  * contributors may be used to endorse or promote products derived from
     17  * this software without specific prior written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 package org.jf.smalidea.findUsages;
     33 
     34 public class FindMethodUsagesTest extends FindUsagesTest {
     35     public void testSmaliUsageInSmaliFile() throws Exception {
     36         addFile("blah.smali", "" +
     37                 ".class public Lblah;\n" +
     38                 ".super Ljava/lang/Object;\n" +
     39                 ".method abstract blah<ref>Method()V\n" +
     40                 ".end method");
     41         addFile("blarg.smali", "" +
     42                 ".class public Lblarg;\n" +
     43                 ".super Ljava/lang/Object;\n" +
     44                 ".method abstract blargMethod()V\n" +
     45                 "  invoke-virtual {v0}, Lblah;->blah<usage>Method()V\n" +
     46                 ".end method");
     47         doTest();
     48     }
     49 
     50     public void testSmaliUsageInJavaFile() throws Exception {
     51         addFile("blah.smali", "" +
     52                 ".class public Lblah;\n" +
     53                 ".super Ljava/lang/Object;\n" +
     54                 ".method abstract blah<ref>Method()V\n" +
     55                 ".end method");
     56         addFile("blarg.java", "" +
     57                 "public class blarg {\n" +
     58                 "    public void blargMethod() {\n" +
     59                 "        blah b = new blah();\n" +
     60                 "        b.blah<usage>Method();\n" +
     61                 "    }\n" +
     62                 "}");
     63         doTest();
     64     }
     65 
     66     public void testJavaUsageInSmaliFile() throws Exception {
     67         addFile("blah.java", "" +
     68                 "public class blah {\n" +
     69                 "    public void blah<ref>Method() {\n" +
     70                 "    }\n" +
     71                 "}");
     72         addFile("blarg.smali", "" +
     73                 ".class public Lblarg;\n" +
     74                 ".super Ljava/lang/Object;\n" +
     75                 ".method abstract blargMethod()V\n" +
     76                 "  invoke-virtual {v0}, Lblah;->blah<usage>Method()V\n" +
     77                 ".end method");
     78         doTest();
     79     }
     80 
     81     public void testPrimitiveListMethod() throws Exception {
     82         addFile("blah.smali", "" +
     83                 ".class public Lblah;\n" +
     84                 ".super Ljava/lang/Object;\n" +
     85                 ".method abstract II<ref>II()V\n" +
     86                 ".end method");
     87         addFile("blarg.smali", "" +
     88                 ".class public Lblarg;\n" +
     89                 ".super Ljava/lang/Object;\n" +
     90                 ".method abstract blargMethod()V\n" +
     91                 "  invoke-virtual {v0}, Lblah;->II<usage>II()V\n" +
     92                 ".end method");
     93        doTest();
     94     }
     95 }
     96