OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/first_run/first_run.h" | 11 #include "chrome/browser/first_run/first_run.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/prefs/session_startup_pref.h" | 13 #include "chrome/browser/prefs/session_startup_pref.h" |
12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_init.h" | 16 #include "chrome/browser/ui/browser_init.h" |
15 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
16 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
17 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/pref_names.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/browser/tab_contents/tab_contents.h" | 23 #include "content/browser/tab_contents/tab_contents.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
22 | 25 |
23 class BrowserInitTest : public ExtensionBrowserTest { | 26 class BrowserInitTest : public ExtensionBrowserTest { |
24 protected: | 27 protected: |
25 // Helper functions return void so that we can ASSERT*(). | 28 // Helper functions return void so that we can ASSERT*(). |
26 // Use ASSERT_NO_FATAL_FAILURE around calls to these functions to stop the | 29 // Use ASSERT_NO_FATAL_FAILURE around calls to these functions to stop the |
27 // test if an assert fails. | 30 // test if an assert fails. |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 300 |
298 // Expect an app panel. | 301 // Expect an app panel. |
299 EXPECT_TRUE(new_browser->is_type_panel() && new_browser->is_app()); | 302 EXPECT_TRUE(new_browser->is_type_panel() && new_browser->is_app()); |
300 | 303 |
301 // The new browser's app_name should include the app's ID. | 304 // The new browser's app_name should include the app's ID. |
302 EXPECT_NE( | 305 EXPECT_NE( |
303 new_browser->app_name_.find(extension_app->id()), | 306 new_browser->app_name_.find(extension_app->id()), |
304 std::string::npos) << new_browser->app_name_; | 307 std::string::npos) << new_browser->app_name_; |
305 } | 308 } |
306 | 309 |
| 310 IN_PROC_BROWSER_TEST_F(BrowserInitTest, ReadingWasRestartedAfterRestart) { |
| 311 // Tests that BrowserInit::WasRestarted reads and resets the preference |
| 312 // kWasRestarted correctly. |
| 313 PrefService* pref_service = g_browser_process->local_state(); |
| 314 pref_service->SetBoolean(prefs::kWasRestarted, true); |
| 315 EXPECT_TRUE(BrowserInit::WasRestarted()); |
| 316 EXPECT_FALSE(pref_service->GetBoolean(prefs::kWasRestarted)); |
| 317 EXPECT_TRUE(BrowserInit::WasRestarted()); |
| 318 } |
| 319 |
| 320 IN_PROC_BROWSER_TEST_F(BrowserInitTest, ReadingWasRestartedAfterNormalStart) { |
| 321 // Tests that BrowserInit::WasRestarted reads and resets the preference |
| 322 // kWasRestarted correctly. |
| 323 PrefService* pref_service = g_browser_process->local_state(); |
| 324 pref_service->SetBoolean(prefs::kWasRestarted, false); |
| 325 EXPECT_FALSE(BrowserInit::WasRestarted()); |
| 326 EXPECT_FALSE(pref_service->GetBoolean(prefs::kWasRestarted)); |
| 327 EXPECT_FALSE(BrowserInit::WasRestarted()); |
| 328 } |
| 329 |
307 #endif // !defined(OS_MACOSX) | 330 #endif // !defined(OS_MACOSX) |
OLD | NEW |