Commit 2be96294 authored by mrefaat's avatar mrefaat Committed by Commit Bot

Remove isVoiceSearchNavigationItem from voice_search_navigations_tab_helper

With voice search bar removal and the tab cleanup this method is not used anymore
deleted it and updated unittests.


Bug: 778416
Change-Id: Ia6a130f50eafb01b0eef265e98ca412071ba7b95
Reviewed-on: https://chromium-review.googlesource.com/c/1355765Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Commit-Queue: Mohammad Refaat <mrefaat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612436}
parent bee91954
...@@ -8,10 +8,6 @@ ...@@ -8,10 +8,6 @@
#import "ios/web/public/web_state/web_state_observer.h" #import "ios/web/public/web_state/web_state_observer.h"
#import "ios/web/public/web_state/web_state_user_data.h" #import "ios/web/public/web_state/web_state_user_data.h"
namespace web {
class NavigationItem;
}
// A helper object that tracks which NavigationItems were created because of // A helper object that tracks which NavigationItems were created because of
// voice search queries. // voice search queries.
class VoiceSearchNavigationTabHelper class VoiceSearchNavigationTabHelper
...@@ -26,9 +22,6 @@ class VoiceSearchNavigationTabHelper ...@@ -26,9 +22,6 @@ class VoiceSearchNavigationTabHelper
// search. // search.
bool IsExpectingVoiceSearch() const; bool IsExpectingVoiceSearch() const;
// Returns whether |item| was created for a voice search query.
bool IsNavigationFromVoiceSearch(const web::NavigationItem* item) const;
private: private:
friend class web::WebStateUserData<VoiceSearchNavigationTabHelper>; friend class web::WebStateUserData<VoiceSearchNavigationTabHelper>;
......
...@@ -43,19 +43,6 @@ bool VoiceSearchNavigationTabHelper::IsExpectingVoiceSearch() const { ...@@ -43,19 +43,6 @@ bool VoiceSearchNavigationTabHelper::IsExpectingVoiceSearch() const {
return will_navigate_to_voice_search_result_; return will_navigate_to_voice_search_result_;
} }
bool VoiceSearchNavigationTabHelper::IsNavigationFromVoiceSearch(
const web::NavigationItem* item) const {
DCHECK(item);
// Check if a voice search navigation is expected if |item| is pending load.
const web::NavigationManager* manager = web_state_->GetNavigationManager();
const web::NavigationItem* pending_item = manager->GetPendingItem();
const web::NavigationItem* transient_item = manager->GetTransientItem();
if (item && (item == pending_item || item == transient_item))
return will_navigate_to_voice_search_result_;
// Check if the marker exists if it's a committed navigation.
return item->GetUserData(kNavigationMarkerKey) != nullptr;
}
void VoiceSearchNavigationTabHelper::NavigationItemCommitted( void VoiceSearchNavigationTabHelper::NavigationItemCommitted(
web::WebState* web_state, web::WebState* web_state,
const web::LoadCommittedDetails& load_details) { const web::LoadCommittedDetails& load_details) {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "ios/web/public/features.h" #include "ios/web/public/features.h"
#import "ios/web/public/navigation_item.h"
#import "ios/web/public/navigation_manager.h" #import "ios/web/public/navigation_manager.h"
#import "ios/web/public/test/web_test_with_web_state.h" #import "ios/web/public/test/web_test_with_web_state.h"
#import "ios/web/public/web_state/web_state.h" #import "ios/web/public/web_state/web_state.h"
...@@ -49,63 +48,13 @@ class VoiceSearchNavigationsTest ...@@ -49,63 +48,13 @@ class VoiceSearchNavigationsTest
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
}; };
// Tests that a NavigationItem is not marked as a voice search if // Tests that a navigation commit reset the value of
// WillLoadVoiceSearchResult() was not called. // IsExpectingVoiceSearch().
// TODO(crbug.com/900667): Re-enable this test. TEST_P(VoiceSearchNavigationsTest, CommitResetVoiceSearchExpectation) {
TEST_P(VoiceSearchNavigationsTest, DISABLED_NotVoiceSearchNavigation) {
LoadHtml(@"<html></html>");
web::NavigationItem* item =
web_state()->GetNavigationManager()->GetLastCommittedItem();
EXPECT_FALSE(navigations()->IsNavigationFromVoiceSearch(item));
}
// Tests that a pending NavigationItem is recorded as a voice search navigation
// if it is added after calling WillLoadVoiceSearchResult().
TEST_P(VoiceSearchNavigationsTest, PendingVoiceSearchNavigation) {
navigations()->WillLoadVoiceSearchResult();
const GURL kPendingUrl("http://pending.test");
AddPendingItem(kPendingUrl, ui::PAGE_TRANSITION_LINK);
web::NavigationItem* item =
web_state()->GetNavigationManager()->GetPendingItem();
EXPECT_TRUE(navigations()->IsNavigationFromVoiceSearch(item));
}
// Tests that a committed NavigationItem is recordored as a voice search
// navigation if it occurs after calling WillLoadVoiceSearchResult().
TEST_P(VoiceSearchNavigationsTest, CommittedVoiceSearchNavigation) {
navigations()->WillLoadVoiceSearchResult(); navigations()->WillLoadVoiceSearchResult();
EXPECT_TRUE(navigations()->IsExpectingVoiceSearch());
LoadHtml(@"<html></html>"); LoadHtml(@"<html></html>");
web::NavigationItem* item = EXPECT_FALSE(navigations()->IsExpectingVoiceSearch());
web_state()->GetNavigationManager()->GetLastCommittedItem();
EXPECT_TRUE(navigations()->IsNavigationFromVoiceSearch(item));
}
// Tests that navigations that occur after a voice search navigation are not
// marked as voice search navigations.
TEST_P(VoiceSearchNavigationsTest, NavigationAfterVoiceSearch) {
navigations()->WillLoadVoiceSearchResult();
const GURL kVoiceSearchUrl("http://voice.test");
LoadHtml(@"<html></html>", kVoiceSearchUrl);
web::NavigationItem* item =
web_state()->GetNavigationManager()->GetLastCommittedItem();
EXPECT_TRUE(navigations()->IsNavigationFromVoiceSearch(item));
// Load another page without calling WillLoadVoiceSearchResult().
const GURL kNonVoiceSearchUrl("http://not-voice.test");
LoadHtml(@"<html></html>", kNonVoiceSearchUrl);
item = web_state()->GetNavigationManager()->GetLastCommittedItem();
EXPECT_FALSE(navigations()->IsNavigationFromVoiceSearch(item));
}
// Tests that transient NavigationItems are handled the same as pending items
TEST_P(VoiceSearchNavigationsTest, TransientNavigations) {
LoadHtml(@"<html></html>", GURL("http://committed_url.test"));
const GURL kTransientURL("http://transient.test");
AddTransientItem(kTransientURL);
web::NavigationItem* item =
web_state()->GetNavigationManager()->GetTransientItem();
EXPECT_FALSE(navigations()->IsNavigationFromVoiceSearch(item));
navigations()->WillLoadVoiceSearchResult();
EXPECT_TRUE(navigations()->IsNavigationFromVoiceSearch(item));
} }
INSTANTIATE_TEST_CASE_P(ProgrammaticVoiceSearchNavigationsTest, INSTANTIATE_TEST_CASE_P(ProgrammaticVoiceSearchNavigationsTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment