chrome/browser/tab_contents/spelling_menu_observer_browsertest.cc
// Test that there will be a separator after "no suggestions" if
// SpellingServiceClient::SUGGEST is on.
Test that there will be a separator after "no suggestions" if
SpellingServiceClient::SUGGEST is on.
Test that there will be a separator after " no suggestions " if SpellingServiceClient :: SUGGEST is on .
IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, SeparatorAfterSuggestions) {
  scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu);
  scoped_ptr<SpellingMenuObserver> observer(
      new SpellingMenuObserver(menu.get()));
  menu->SetObserver(observer.get());
  menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true);
  menu->CreateRequestContext();
  menu->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "en");
  EXPECT_TRUE(SpellingServiceClient::IsAvailable(menu->GetProfile(),
    SpellingServiceClient::SUGGEST));
  content::ContextMenuParams params;
  params.is_editable = true;
  params.misspelled_word = ASCIIToUTF16("jhhj");
  observer->InitMenu(params);
  EXPECT_LT(3U, menu->GetMenuSize());
  MockRenderViewContextMenu::MockMenuItem item;
  menu->GetMenuItem(0, &item);
  EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id);
  EXPECT_FALSE(item.enabled);
  EXPECT_FALSE(item.hidden);
  menu->GetMenuItem(1, &item);
  EXPECT_EQ(IDC_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS, item.command_id);
  EXPECT_FALSE(item.enabled);
  EXPECT_FALSE(item.hidden);
  menu->GetMenuItem(2, &item);
  EXPECT_EQ(-1, item.command_id);
  EXPECT_FALSE(item.enabled);
  EXPECT_FALSE(item.hidden);
}
IN_PROC_BROWSER_TEST_F ( SpellingMenuObserverTest , SeparatorAfterSuggestions ) { scoped_ptr < MockRenderViewContextMenu > menu ( new MockRenderViewContextMenu ) ; scoped_ptr < SpellingMenuObserver > observer ( new SpellingMenuObserver ( menu . get ( ) ) ) ; menu -> SetObserver ( observer . get ( ) ) ; menu -> GetPrefs ( ) -> SetBoolean ( prefs :: kSpellCheckUseSpellingService , true ) ; menu -> CreateRequestContext ( ) ; menu -> GetPrefs ( ) -> SetString ( prefs :: kSpellCheckDictionary , " " ) ; EXPECT_TRUE ( SpellingServiceClient :: IsAvailable ( menu -> GetProfile ( ) , SpellingServiceClient :: SUGGEST ) ) ; content :: ContextMenuParams params ; params . is_editable = true ; params . misspelled_word = ASCIIToUTF16 ( " " ) ; observer -> InitMenu ( params ) ; EXPECT_LT ( 3U , menu -> GetMenuSize ( ) ) ; MockRenderViewContextMenu :: MockMenuItem item ; menu -> GetMenuItem ( 0 , & item ) ; EXPECT_EQ ( IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION , item . command_id ) ; EXPECT_FALSE ( item . enabled ) ; EXPECT_FALSE ( item . hidden ) ; menu -> GetMenuItem ( 1 , & item ) ; EXPECT_EQ ( IDC_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS , item . command_id ) ; EXPECT_FALSE ( item . enabled ) ; EXPECT_FALSE ( item . hidden ) ; menu -> GetMenuItem ( 2 , & item ) ; EXPECT_EQ ( -1 , item . command_id ) ; EXPECT_FALSE ( item . enabled ) ; EXPECT_FALSE ( item . hidden ) ; }
Test that there will be a separator after "no suggestions" if
SpellingServiceClient::SUGGEST is on.
Test that there will be a separator after " no suggestions " if SpellingServiceClient :: SUGGEST is on .
// Make sure we can pretend to handle the JSON request. // Force a non-empty locale so SUGGEST is available. // The test should see "No spelling suggestions" (from system checker), // "No more Google suggestions" (from SpellingService) and a separator // as the first three items, then possibly more (not relevant here).