Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Unified Diff: components/search_engines/desktop_search_infobar_delegate_win_unittest.cc

Issue 1598553003: Implement the Windows desktop search redirection feature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: don't assume that a Browser exists + fix nits Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+}

Powered by Google App Engine
This is Rietveld 408576698