Chromium Code Reviews| Index: components/search_engines/desktop_search_infobar_delegate_win_unittest.cc |
| diff --git a/components/search_engines/desktop_search_infobar_delegate_win_unittest.cc b/components/search_engines/desktop_search_infobar_delegate_win_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e8c58a711f0fa37dcb6330f62831c9a00976851f |
| --- /dev/null |
| +++ b/components/search_engines/desktop_search_infobar_delegate_win_unittest.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/search_engines/desktop_search_infobar_delegate_win.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/strings/string16.h" |
| +#include "components/infobars/core/infobar.h" |
| +#include "components/infobars/core/infobar_manager.h" |
| +#include "components/search_engines/desktop_search_utils_win.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace { |
| + |
| +class MockInfoBarManager : public infobars::InfoBarManager { |
| + public: |
| + // infobars::InfoBarManager: |
| + int GetActiveEntryID() override { return 0; } |
| + |
| + scoped_ptr<infobars::InfoBar> CreateConfirmInfoBar( |
| + scoped_ptr<ConfirmInfoBarDelegate> delegate) override { |
| + NOTREACHED(); |
| + return scoped_ptr<infobars::InfoBar>(); |
| + } |
| + |
| + MOCK_METHOD2(OpenURL, |
| + void(const GURL& url, WindowOpenDisposition disposition)); |
| +}; |
| + |
| +const base::char16 kSearchSettingsURL[] = L"chrome://settings/searchEngines"; |
|
Peter Kasting
2016/01/20 03:03:02
I wouldn't use the real chrome: URL in a component
fdoray
2016/01/21 21:02:33
Removed the test.
|
| + |
| +} // namespace |
| + |
| +TEST(WindowsDesktopSearchInfobarDelegateTest, ManageSearchSettings) { |
|
Peter Kasting
2016/01/20 03:03:02
Does this test really matter? It seems like it's
fdoray
2016/01/21 21:02:33
Removed the test.
|
| + // Create a Windows desktop search redirection infobar. |
| + infobars::InfoBar* infobar = |
| + new infobars::InfoBar(scoped_ptr<infobars::InfoBarDelegate>( |
|
Peter Kasting
2016/01/20 03:03:02
Nit: make_scoped_ptr()?
fdoray
2016/01/21 21:02:33
Removed the test.
|
| + new WindowsDesktopSearchInfobarDelegate(L"Google", |
| + GURL(kSearchSettingsURL)))); |
| + MockInfoBarManager infobar_manager; |
| + infobar->SetOwner(&infobar_manager); |
| + |
| + EXPECT_CALL(infobar_manager, |
| + OpenURL(GURL(kSearchSettingsURL), NEW_FOREGROUND_TAB)); |
| + EXPECT_FALSE(infobar->delegate()->AsConfirmInfoBarDelegate()->Accept()); |
| + |
| + // This calls the destructor of |infobar|. |
| + infobar->CloseSoon(); |
| +} |