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

Side by Side Diff: chrome/browser/sessions/better_session_restore_browsertest.cc

Issue 12210067: Get rid of native-desktop-only BrowserList:: iterator methods in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge up to r181832 Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
13 #include "chrome/browser/api/infobars/infobar_service.h" 13 #include "chrome/browser/api/infobars/infobar_service.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/enterprise_extension_observer.h" 15 #include "chrome/browser/chromeos/enterprise_extension_observer.h"
16 #include "chrome/browser/content_settings/cookie_settings.h" 16 #include "chrome/browser/content_settings/cookie_settings.h"
17 #include "chrome/browser/prefs/session_startup_pref.h" 17 #include "chrome/browser/prefs/session_startup_pref.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_impl.h" 19 #include "chrome/browser/profiles/profile_impl.h"
20 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/sessions/session_backend.h" 21 #include "chrome/browser/sessions/session_backend.h"
22 #include "chrome/browser/sessions/session_service_factory.h" 22 #include "chrome/browser/sessions/session_service_factory.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_commands.h" 24 #include "chrome/browser/ui/browser_commands.h"
25 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_iterator.h"
26 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/startup/startup_browser_creator.h" 27 #include "chrome/browser/ui/startup/startup_browser_creator.h"
28 #include "chrome/browser/ui/tabs/tab_strip_model.h" 28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
29 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/content_settings.h" 30 #include "chrome/common/content_settings.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
33 #include "chrome/test/base/in_process_browser_test.h" 33 #include "chrome/test/base/in_process_browser_test.h"
34 #include "chrome/test/base/ui_test_utils.h" 34 #include "chrome/test/base/ui_test_utils.h"
35 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "content/public/common/url_constants.h" 36 #include "content/public/common/url_constants.h"
37 #include "content/public/test/browser_test_utils.h" 37 #include "content/public/test/browser_test_utils.h"
38 #include "net/base/net_util.h" 38 #include "net/base/net_util.h"
39 #include "net/base/upload_bytes_element_reader.h" 39 #include "net/base/upload_bytes_element_reader.h"
40 #include "net/base/upload_data_stream.h" 40 #include "net/base/upload_data_stream.h"
41 #include "net/url_request/url_request.h" 41 #include "net/url_request/url_request.h"
42 #include "net/url_request/url_request_filter.h" 42 #include "net/url_request/url_request_filter.h"
43 #include "net/url_request/url_request_test_job.h" 43 #include "net/url_request/url_request_test_job.h"
44 44
45 namespace { 45 namespace {
46 46
47 Browser* FindOneOtherBrowserForProfile(Profile* profile, 47 Browser* FindOneOtherBrowserForProfile(Profile* profile,
48 Browser* not_this_browser) { 48 Browser* not_this_browser) {
49 for (BrowserList::const_iterator i = BrowserList::begin(); 49 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
50 i != BrowserList::end(); ++i) { 50 if (*it != not_this_browser && it->profile() == profile)
51 if (*i != not_this_browser && (*i)->profile() == profile) 51 return *it;
52 return *i;
53 } 52 }
54 return NULL; 53 return NULL;
55 } 54 }
56 55
57 // We need to serve the test files so that PRE_Test and Test can access the same 56 // We need to serve the test files so that PRE_Test and Test can access the same
58 // page using the same URL. In addition, perceived security origin of the page 57 // page using the same URL. In addition, perceived security origin of the page
59 // needs to stay the same, so e.g., redirecting the URL requests doesn't 58 // needs to stay the same, so e.g., redirecting the URL requests doesn't
60 // work. (If we used a test server, the PRE_Test and Test would have separate 59 // work. (If we used a test server, the PRE_Test and Test would have separate
61 // instances running on separate ports.) 60 // instances running on separate ports.)
62 61
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 CheckFormRestored(false, false); 361 CheckFormRestored(false, false);
363 } 362 }
364 363
365 class RestartTest : public BetterSessionRestoreTest { 364 class RestartTest : public BetterSessionRestoreTest {
366 public: 365 public:
367 RestartTest() { } 366 RestartTest() { }
368 virtual ~RestartTest() { } 367 virtual ~RestartTest() { }
369 protected: 368 protected:
370 void Restart() { 369 void Restart() {
371 // Simluate restarting the browser, but let the test exit peacefully. 370 // Simluate restarting the browser, but let the test exit peacefully.
372 BrowserList::const_iterator it; 371 for (chrome::BrowserIterator it; !it.done(); it.Next())
373 for (it = BrowserList::begin(); it != BrowserList::end(); ++it) 372 content::BrowserContext::SaveSessionState(it->profile());
374 content::BrowserContext::SaveSessionState((*it)->profile());
375 PrefService* pref_service = g_browser_process->local_state(); 373 PrefService* pref_service = g_browser_process->local_state();
376 pref_service->SetBoolean(prefs::kWasRestarted, true); 374 pref_service->SetBoolean(prefs::kWasRestarted, true);
377 #if defined(OS_WIN) 375 #if defined(OS_WIN)
378 if (pref_service->HasPrefPath(prefs::kRestartSwitchMode)) 376 if (pref_service->HasPrefPath(prefs::kRestartSwitchMode))
379 pref_service->SetBoolean(prefs::kRestartSwitchMode, false); 377 pref_service->SetBoolean(prefs::kRestartSwitchMode, false);
380 #endif 378 #endif
381 } 379 }
382 380
383 private: 381 private:
384 DISALLOW_COPY_AND_ASSIGN(RestartTest); 382 DISALLOW_COPY_AND_ASSIGN(RestartTest);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 595 }
598 596
599 private: 597 private:
600 DISALLOW_COPY_AND_ASSIGN(BetterSessionRestoreCrashTest); 598 DISALLOW_COPY_AND_ASSIGN(BetterSessionRestoreCrashTest);
601 }; 599 };
602 600
603 // http://crbug.com/172770 601 // http://crbug.com/172770
604 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreCrashTest, DISABLED_SessionCookies) { 602 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreCrashTest, DISABLED_SessionCookies) {
605 CrashTestWithPage("session_cookies.html"); 603 CrashTestWithPage("session_cookies.html");
606 } 604 }
OLDNEW
« no previous file with comments | « chrome/browser/fast_shutdown_browsertest.cc ('k') | chrome/browser/sessions/session_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698