(t *testing.T)
| 111 | } |
| 112 | |
| 113 | func TestInvokeMethod(t *testing.T) { |
| 114 | ctx := log.Testing(t) |
| 115 | |
| 116 | class, err := connection.GetClassBySignature("LCalculator;") |
| 117 | if err != nil { |
| 118 | log.F(ctx, true, "GetClassesBySignature returned error: %v", err) |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | methods, err := connection.GetMethods(class.TypeID) |
| 123 | if err != nil { |
| 124 | log.F(ctx, true, "GetMethods returned error: %v", err) |
| 125 | return |
| 126 | } |
| 127 | |
| 128 | constructor := methods.FindBySignature("<init>", "()V") |
| 129 | if constructor == nil { |
| 130 | log.F(ctx, true, "Couldn't find constructor: %v", err) |
| 131 | log.I(ctx, "Available methods:\n%v", methods) |
| 132 | return |
| 133 | } |
| 134 | |
| 135 | instance, err := connection.NewInstance(class.ClassID(), constructor.ID, thread, jdwp.InvokeSingleThreaded) |
| 136 | if err != nil { |
| 137 | log.F(ctx, true, "NewInstance returned error: %v", err) |
| 138 | return |
| 139 | } |
| 140 | |
| 141 | add := methods.FindBySignature("Add", "(I)V") |
| 142 | if add == nil { |
| 143 | log.F(ctx, true, "Couldn't find method Add: %v", err) |
| 144 | log.I(ctx, "Available methods:\n%v", methods) |
| 145 | return |
| 146 | } |
| 147 | |
| 148 | for _, i := range []int{3, 6, 8} { |
| 149 | _, err = connection.InvokeMethod( |
| 150 | instance.Result.Object, |
| 151 | class.ClassID(), |
| 152 | add.ID, |
| 153 | thread, |
| 154 | jdwp.InvokeSingleThreaded, |
| 155 | i) |
| 156 | if err != nil { |
| 157 | log.F(ctx, true, "InvokeMethod returned error: %v", err) |
| 158 | return |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | resultf := methods.FindBySignature("Result", "()I") |
| 163 | if resultf == nil { |
| 164 | log.F(ctx, true, "Couldn't find method Result: %v", err) |
| 165 | log.I(ctx, "Available methods:\n%v", methods) |
| 166 | return |
| 167 | } |
| 168 | |
| 169 | result, err := connection.InvokeMethod( |
| 170 | instance.Result.Object, |
nothing calls this directly
no test coverage detected