src/developer/debug/zxdb/console/input_location_parser_unittest.cc
// Most of the prefix searching is tested by the FindName tests. This just tests the integration of
// that with the InputLocation completion.
Most of the prefix searching is tested by the FindName tests. This just tests the integration of
that with the InputLocation completion.
Most of the prefix searching is tested by the FindName tests . This just tests the integration of that with the InputLocation completion .
TEST_F(InputLocationParserTest, CompleteInputLocation) {
  auto& root = mock_module_symbols_->index().root();
  const char kGlobalName[] = "aGlobalFunction";
  auto global_func = fxl::MakeRefCounted<Function>(DwarfTag::kSubprogram);
  global_func->set_assigned_name(kGlobalName);
  TestIndexedSymbol indexed_global(mock_module_symbols_, &root, kGlobalName, global_func);
  const char kNsName[] = "aNamespace";
  auto ns = fxl::MakeRefCounted<Namespace>();
  ns->set_assigned_name(kNsName);
  TestIndexedSymbol indexed_ns(mock_module_symbols_, &root, kNsName, ns);
  const char kClassName[] = "Class";
  auto global_type = fxl::MakeRefCounted<Collection>(DwarfTag::kClassType);
  SymbolTestParentSetter global_type_parent(global_type, ns);
  global_type->set_assigned_name(kClassName);
  TestIndexedSymbol indexed_type(mock_module_symbols_, indexed_ns.index_node, kClassName,
                                 global_type);
  const char kMemberName[] = "MemberFunction";
  auto member_func = fxl::MakeRefCounted<Function>(DwarfTag::kSubprogram);
  member_func->set_assigned_name(kMemberName);
  SymbolTestParentSetter member_func_parent(member_func, global_type);
  TestIndexedSymbol indexed_member(mock_module_symbols_, indexed_type.index_node, kMemberName,
                                   member_func);
  Session session;
  MockTarget target(&session);
  target.set_symbols(&symbols_.target());
  MockProcess process(&session);
  process.set_symbols(&symbols_.process());
  Location loc;
  MockFrame frame(&session, nullptr, loc, 0);
  target.SetRunningProcess(&process);
  Command command;
  command.set_verb(Verb::kBreak);
  command.set_target(&target);
  command.set_frame(&frame);
  std::vector<std::string> found;
  CompleteInputLocation(command, "a", &found);
  ASSERT_EQ(2u, found.size());
  EXPECT_EQ("aNamespace::", found[0]);  s get "::" appended.
  EXPECT_EQ(std::string("::") + kGlobalName, found[1]);
  found.clear();
  CompleteInputLocation(command, "aNamespace::", &found);
  ASSERT_TRUE(found.empty());
  found.clear();
  CompleteInputLocation(command, "aNamespace::Cl", &found);
  ASSERT_EQ(1u, found.size());
  EXPECT_EQ("::aNamespace::Class::", found[0]);  
  found.clear();
  CompleteInputLocation(command, "aNamespace::Class::M", &found);
  ASSERT_EQ(1u, found.size());
  EXPECT_EQ("::aNamespace::Class::MemberFunction", found[0]);
}
TEST_F ( InputLocationParserTest , CompleteInputLocation ) { auto & root = mock_module_symbols_ -> index ( ) . root ( ) ; const char kGlobalName [ ] = " " ; auto global_func = fxl :: MakeRefCounted < Function > ( DwarfTag :: kSubprogram ) ; global_func -> set_assigned_name ( kGlobalName ) ; TestIndexedSymbol indexed_global ( mock_module_symbols_ , & root , kGlobalName , global_func ) ; const char kNsName [ ] = " " ; auto ns = fxl :: MakeRefCounted < Namespace > ( ) ; ns -> set_assigned_name ( kNsName ) ; TestIndexedSymbol indexed_ns ( mock_module_symbols_ , & root , kNsName , ns ) ; const char kClassName [ ] = " " ; auto global_type = fxl :: MakeRefCounted < Collection > ( DwarfTag :: kClassType ) ; SymbolTestParentSetter global_type_parent ( global_type , ns ) ; global_type -> set_assigned_name ( kClassName ) ; TestIndexedSymbol indexed_type ( mock_module_symbols_ , indexed_ns . index_node , kClassName , global_type ) ; const char kMemberName [ ] = " " ; auto member_func = fxl :: MakeRefCounted < Function > ( DwarfTag :: kSubprogram ) ; member_func -> set_assigned_name ( kMemberName ) ; SymbolTestParentSetter member_func_parent ( member_func , global_type ) ; TestIndexedSymbol indexed_member ( mock_module_symbols_ , indexed_type . index_node , kMemberName , member_func ) ; Session session ; MockTarget target ( & session ) ; target . set_symbols ( & symbols_ . target ( ) ) ; MockProcess process ( & session ) ; process . set_symbols ( & symbols_ . process ( ) ) ; Location loc ; MockFrame frame ( & session , nullptr , loc , 0 ) ; target . SetRunningProcess ( & process ) ; Command command ; command . set_verb ( Verb :: kBreak ) ; command . set_target ( & target ) ; command . set_frame ( & frame ) ; std :: vector < std :: string > found ; CompleteInputLocation ( command , " " , & found ) ; ASSERT_EQ ( 2u , found . size ( ) ) ; EXPECT_EQ ( " " , found [ 0 ] ) ; EXPECT_EQ ( std :: string ( " " ) + kGlobalName , found [ 1 ] ) ; found . clear ( ) ; CompleteInputLocation ( command , " " , & found ) ; ASSERT_TRUE ( found . empty ( ) ) ; found . clear ( ) ; CompleteInputLocation ( command , " " , & found ) ; ASSERT_EQ ( 1u , found . size ( ) ) ; EXPECT_EQ ( " " , found [ 0 ] ) ; found . clear ( ) ; CompleteInputLocation ( command , " " , & found ) ; ASSERT_EQ ( 1u , found . size ( ) ) ; EXPECT_EQ ( " " , found [ 0 ] ) ; }
Most of the prefix searching is tested by the FindName tests.
Most of the prefix searching is tested by the FindName tests .
// Global function. // Namespace // Class inside the namespace. // Function inside the class. // TODO(brettw) make a test setup helper for a whole session / target / process / thread / frame + // symbols. // TEST CODE ------------------------------------------------------------------------------------- // "a" should complete to both "aNamespace" and "aGlobalFunction" (in that order). // Namespaces get "::" appended. // "aNamespace::" doesn't complete to anything. It might be nice to have this complete to all // functions in the namespace, but we don't implement that yet. In the meantime, at least test // this does what we currently expect. // Completing classes. // Classes get "::" appended. // Completing class member functions.