예제 #1
0
void create_scope() {
  auto obj_t = DexType::make_type("Ljava/lang/Object;");
  auto int_t = DexType::make_type("I");
  auto string_t = DexType::make_type("Ljava/lang/String;");
  auto a = DexType::make_type("A");
  auto b = DexType::make_type("B");
  auto c = DexType::make_type("C");
  auto d = DexType::make_type("D");
  auto u = DexType::make_type("U");
  auto e = DexType::make_type("E");
  auto cls_A = create_class(a, obj_t,
      {make_field_def(a, "f1", int_t, ACC_PUBLIC, true)},
      ACC_PUBLIC, true);
  auto cls_B = create_class(b, a,
      {make_field_def(b, "f2", string_t, ACC_PUBLIC | ACC_STATIC)});
  auto cls_C = create_class(c, b, {});
  auto cls_D = create_class(d, obj_t, {make_field_def(d, "f", a)});
  auto cls_E = create_class(e, obj_t, {});
}
예제 #2
0
TEST(RenameMembers, rename) {
  g_redex = new RedexContext();
  auto obj_t = DexType::make_type("Ljava/lang/Object;");
  auto int_t = DexType::make_type("I");
  auto a = DexType::make_type("A");
  auto field = make_field_def(a, "wombat", int_t, ACC_PUBLIC, true);
  auto cls_A = create_class(a, obj_t, {field}, ACC_PUBLIC, true);
  std::string name_before = field->get_name()->c_str();
  ASSERT_EQ("wombat", name_before);
  DexFieldSpec spec;
  spec.name = DexString::make_string("numbat");
  field->change(spec);
  std::string name_after = field->get_name()->c_str();
  ASSERT_EQ("numbat", name_after);
}