Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / chrome / renderer / searchbox / search_bouncer_unittest.cc
blob999559e6cf4d5eb067e3d42b9811acedab0c2ffb
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/renderer/searchbox/search_bouncer.h"
7 #include <vector>
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/common/render_messages.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h"
14 class SearchBouncerTest : public testing::Test {
15 public:
16 void SetUp() override {
17 bouncer_.reset(new SearchBouncer);
18 std::vector<GURL> search_urls;
19 search_urls.push_back(GURL("http://example.com/search"));
20 search_urls.push_back(GURL("http://example.com/search2"));
21 bouncer_->OnSetSearchURLs(search_urls, GURL("http://example.com/newtab"));
24 scoped_ptr<SearchBouncer> bouncer_;
27 TEST_F(SearchBouncerTest, ShouldFork) {
28 EXPECT_FALSE(bouncer_->ShouldFork(GURL()));
29 EXPECT_FALSE(bouncer_->ShouldFork(GURL("http://notsearch.example.com")));
30 EXPECT_TRUE(bouncer_->ShouldFork(GURL("http://example.com/search?q=foo")));
31 EXPECT_TRUE(bouncer_->ShouldFork(GURL("http://example.com/search2#q=foo")));
32 EXPECT_TRUE(bouncer_->ShouldFork(GURL("http://example.com/newtab")));
35 TEST_F(SearchBouncerTest, IsNewTabPage) {
36 EXPECT_FALSE(bouncer_->IsNewTabPage(GURL("http://example.com/foo")));
37 EXPECT_TRUE(bouncer_->IsNewTabPage(GURL("http://example.com/newtab")));
40 TEST_F(SearchBouncerTest, SetSearchURLs) {
41 std::vector<GURL> search_urls;
42 search_urls.push_back(GURL("http://other.example.com/search"));
43 const GURL new_tab_page_url(GURL("http://other.example.com/newtab"));
44 EXPECT_TRUE(bouncer_->OnControlMessageReceived(
45 ChromeViewMsg_SetSearchURLs(search_urls, new_tab_page_url)));
46 EXPECT_EQ(search_urls, bouncer_->search_urls_);
47 EXPECT_EQ(new_tab_page_url, bouncer_->new_tab_page_url_);