summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_init_browsertest.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-09 04:00:19 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-09 04:00:19 +0000
commit8b0e9cc3bc9045321e746f466a0c65cbbf9b9f2b (patch)
tree9f12716108f71cdaca0fb8de33d4257d187b6e38 /chrome/browser/ui/browser_init_browsertest.cc
parentea993c2cb08e5e8915b369fb17087d29776cad1f (diff)
downloadchromium_src-8b0e9cc3bc9045321e746f466a0c65cbbf9b9f2b.zip
chromium_src-8b0e9cc3bc9045321e746f466a0c65cbbf9b9f2b.tar.gz
chromium_src-8b0e9cc3bc9045321e746f466a0c65cbbf9b9f2b.tar.bz2
Move more files to chrome/browser/ui
TBR=brettw BUG=none TEST=none Review URL: http://codereview.chromium.org/4720002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_init_browsertest.cc')
-rw-r--r--chrome/browser/ui/browser_init_browsertest.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome/browser/ui/browser_init_browsertest.cc b/chrome/browser/ui/browser_init_browsertest.cc
new file mode 100644
index 0000000..d036c4d
--- /dev/null
+++ b/chrome/browser/ui/browser_init_browsertest.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 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 "base/command_line.h"
+#include "base/file_path.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_init.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class BrowserInitTest : public InProcessBrowserTest {
+};
+
+class OpenURLsPopupObserver : public BrowserList::Observer {
+ public:
+ OpenURLsPopupObserver() : added_browser_(NULL) { }
+
+ virtual void OnBrowserAdded(const Browser* browser) {
+ added_browser_ = browser;
+ }
+
+ virtual void OnBrowserRemoved(const Browser* browser) { }
+
+ const Browser* added_browser_;
+};
+
+// Test that when there is a popup as the active browser any requests to
+// BrowserInit::LaunchWithProfile::OpenURLsInBrowser don't crash because
+// there's no explicit profile given.
+IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) {
+ std::vector<GURL> urls;
+ urls.push_back(GURL("http://localhost"));
+
+ // Note that in our testing we do not ever query the BrowserList for the "last
+ // active" browser. That's because the browsers are set as "active" by
+ // platform UI toolkit messages, and those messages are not sent during unit
+ // testing sessions.
+
+ OpenURLsPopupObserver observer;
+ BrowserList::AddObserver(&observer);
+
+ Browser* popup = Browser::CreateForType(Browser::TYPE_POPUP,
+ browser()->profile());
+ ASSERT_EQ(popup->type(), Browser::TYPE_POPUP);
+ ASSERT_EQ(popup, observer.added_browser_);
+
+ CommandLine dummy(CommandLine::NO_PROGRAM);
+ BrowserInit::LaunchWithProfile launch(FilePath(), dummy);
+ // This should create a new window, but re-use the profile from |popup|. If
+ // it used a NULL or invalid profile, it would crash.
+ launch.OpenURLsInBrowser(popup, false, urls);
+ ASSERT_NE(popup, observer.added_browser_);
+ BrowserList::RemoveObserver(&observer);
+}
+
+} // namespace