OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #include "components/search_engines/desktop_search_infobar_delegate_win.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string16.h" |
| 10 #include "components/infobars/core/infobar.h" |
| 11 #include "components/infobars/core/infobar_manager.h" |
| 12 #include "components/search_engines/desktop_search_utils_win.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 |
| 16 namespace { |
| 17 |
| 18 class MockInfoBarManager : public infobars::InfoBarManager { |
| 19 public: |
| 20 // infobars::InfoBarManager: |
| 21 int GetActiveEntryID() override { return 0; } |
| 22 |
| 23 scoped_ptr<infobars::InfoBar> CreateConfirmInfoBar( |
| 24 scoped_ptr<ConfirmInfoBarDelegate> delegate) override { |
| 25 NOTREACHED(); |
| 26 return scoped_ptr<infobars::InfoBar>(); |
| 27 } |
| 28 |
| 29 MOCK_METHOD2(OpenURL, |
| 30 void(const GURL& url, WindowOpenDisposition disposition)); |
| 31 }; |
| 32 |
| 33 const base::char16 kSearchSettingsURL[] = L"chrome://settings/searchEngines"; |
| 34 |
| 35 } // namespace |
| 36 |
| 37 TEST(WindowsDesktopSearchInfobarDelegateTest, ManageSearchSettings) { |
| 38 // Create a Windows desktop search redirection infobar. |
| 39 infobars::InfoBar* infobar = |
| 40 new infobars::InfoBar(scoped_ptr<infobars::InfoBarDelegate>( |
| 41 new WindowsDesktopSearchInfobarDelegate(L"Google", |
| 42 GURL(kSearchSettingsURL)))); |
| 43 MockInfoBarManager infobar_manager; |
| 44 infobar->SetOwner(&infobar_manager); |
| 45 |
| 46 EXPECT_CALL(infobar_manager, |
| 47 OpenURL(GURL(kSearchSettingsURL), NEW_FOREGROUND_TAB)); |
| 48 EXPECT_FALSE(infobar->delegate()->AsConfirmInfoBarDelegate()->Accept()); |
| 49 |
| 50 // This calls the destructor of |infobar|. |
| 51 infobar->CloseSoon(); |
| 52 } |
OLD | NEW |