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

Side by Side Diff: chrome/browser/browser_init_browsertest.cc

Issue 164341: Ensure we have a valid profile when using... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_init.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 "chrome/browser/browser.h"
6 #include "chrome/browser/browser_init.h"
7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/browser_window.h"
9 #include "chrome/browser/views/frame/browser_view.h"
10 #include "chrome/test/in_process_browser_test.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace {
14
15 class BrowserInitTest : public InProcessBrowserTest {
16 };
17
18 class OpenURLsPopupObserver : public BrowserList::Observer {
19 public:
20 OpenURLsPopupObserver() : added_browser_(NULL) { }
21
22 virtual void OnBrowserAdded(const Browser* browser) {
23 added_browser_ = browser;
24 }
25
26 virtual void OnBrowserRemoving(const Browser* browser) { }
27
28 const Browser* added_browser_;
29 };
30
31 // Test that when there is a popup as the active browser any requests to
32 // BrowserInit::LaunchWithProfile::OpenURLsInBrowser don't crash because
33 // there's no explicit profile given.
34 IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) {
35 std::vector<GURL> urls;
36 urls.push_back(GURL("http://www.google.com"));
37 urls.push_back(GURL("http://dev.chromium.org"));
38
39 // Note that in our testing we do not ever query the BrowserList for the "last
40 // active" browser. That's because the browsers are set as "active" by
41 // platform UI toolkit messages, and those messages are not sent during unit
42 // testing sessions.
43
44 OpenURLsPopupObserver observer;
45 BrowserList::AddObserver(&observer);
46
47 Browser* popup = Browser::CreateForPopup(browser()->profile());
48 ASSERT_EQ(popup->type(), Browser::TYPE_POPUP);
49 ASSERT_EQ(popup, observer.added_browser_);
50
51 CommandLine dummy((std::wstring()));
52 BrowserInit::LaunchWithProfile launch(std::wstring(), dummy);
53 // This should create a new window, but re-use the profile from |popup|. If
54 // it used a NULL or invalid profile, it would crash.
55 launch.OpenURLsInBrowser(popup, false, urls);
56 ASSERT_NE(popup, observer.added_browser_);
57 BrowserList::RemoveObserver(&observer);
58 }
59
60 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/browser_init.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698