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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_impl_unittest.cc

Issue 2832503002: Fix double session-restore bug. (Closed)
Patch Set: Fix unittest. Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ui/startup/startup_browser_creator_impl.h" 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/ui/startup/startup_tab_provider.h" 8 #include "chrome/browser/ui/startup/startup_tab_provider.h"
9 #include "chrome/common/url_constants.cc" 9 #include "chrome/common/url_constants.cc"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output); 246 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output);
247 } 247 }
248 248
249 TEST(StartupBrowserCreatorImplTest, DetermineBrowserOpenBehavior_PostCrash) { 249 TEST(StartupBrowserCreatorImplTest, DetermineBrowserOpenBehavior_PostCrash) {
250 SessionStartupPref pref_last(SessionStartupPref::Type::LAST); 250 SessionStartupPref pref_last(SessionStartupPref::Type::LAST);
251 251
252 // Launching after crash should block session restore. 252 // Launching after crash should block session restore.
253 Creator::BrowserOpenBehavior output = Creator::DetermineBrowserOpenBehavior( 253 Creator::BrowserOpenBehavior output = Creator::DetermineBrowserOpenBehavior(
254 pref_last, Creator::PROCESS_STARTUP | Creator::IS_POST_CRASH_LAUNCH); 254 pref_last, Creator::PROCESS_STARTUP | Creator::IS_POST_CRASH_LAUNCH);
255 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output); 255 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output);
256
257 // Exception: this can be overridden by passing a switch.
258 output = Creator::DetermineBrowserOpenBehavior(
259 pref_last, Creator::PROCESS_STARTUP | Creator::IS_POST_CRASH_LAUNCH |
260 Creator::HAS_RESTORE_SWITCH);
261 EXPECT_EQ(Creator::BrowserOpenBehavior::SYNCHRONOUS_RESTORE, output);
262 } 256 }
263 257
264 TEST(StartupBrowserCreatorImplTest, DetermineBrowserOpenBehavior_NotStartup) { 258 TEST(StartupBrowserCreatorImplTest, DetermineBrowserOpenBehavior_NotStartup) {
265 SessionStartupPref pref_default(SessionStartupPref::Type::DEFAULT); 259 SessionStartupPref pref_default(SessionStartupPref::Type::DEFAULT);
266 SessionStartupPref pref_last(SessionStartupPref::Type::LAST); 260 SessionStartupPref pref_last(SessionStartupPref::Type::LAST);
267 SessionStartupPref pref_urls(SessionStartupPref::Type::URLS); 261 SessionStartupPref pref_urls(SessionStartupPref::Type::URLS);
268 262
269 // Launch after startup without command-line tabs should always create a new 263 // Launch after startup without command-line tabs should always create a new
270 // window. 264 // window.
271 Creator::BrowserOpenBehavior output = 265 Creator::BrowserOpenBehavior output =
272 Creator::DetermineBrowserOpenBehavior(pref_default, 0); 266 Creator::DetermineBrowserOpenBehavior(pref_default, 0);
273 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output); 267 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output);
274 268
275 output = Creator::DetermineBrowserOpenBehavior(pref_last, 0); 269 output = Creator::DetermineBrowserOpenBehavior(pref_last, 0);
276 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output); 270 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output);
277 271
278 output = Creator::DetermineBrowserOpenBehavior(pref_urls, 0); 272 output = Creator::DetermineBrowserOpenBehavior(pref_urls, 0);
279 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output); 273 EXPECT_EQ(Creator::BrowserOpenBehavior::NEW, output);
280 } 274 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator_impl.cc ('k') | chrome/common/chrome_switches.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698