Commit 7499de42 authored by Wei Li's avatar Wei Li Committed by Commit Bot

Re-enable AttemptRestart test

The test was disabled because ChromeOS will exit the test. But it is no
longer the case on ChromeOS. Let's enable it.

It is a bit weird to have this test inside
tab_contents_iterator_unittest.cc since it has little to do with tab
content. This CL moves the test to chrome/browser/lifetime/ since it
tests whether AttemptRestart() sets the preference correctly. We also
clean up the headers.

BUG=none

Change-Id: I663a0a7159b325b3783d816bec1d518ad7da7adb
Reviewed-on: https://chromium-review.googlesource.com/c/1352573
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611558}
parent 09e4c122
// Copyright 2018 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 "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/prefs/testing_pref_service.h"
using ApplicationLifetimeTest = BrowserWithTestWindowTest;
TEST_F(ApplicationLifetimeTest, AttemptRestart) {
ASSERT_TRUE(g_browser_process);
TestingPrefServiceSimple* testing_pref_service =
profile_manager()->local_state()->Get();
EXPECT_FALSE(testing_pref_service->GetBoolean(prefs::kWasRestarted));
chrome::AttemptRestart();
EXPECT_TRUE(testing_pref_service->GetBoolean(prefs::kWasRestarted));
// Cancel the effects of us calling chrome::AttemptRestart. Otherwise tests
// ran after this one will fail.
browser_shutdown::SetTryingToQuit(false);
}
...@@ -4,29 +4,17 @@ ...@@ -4,29 +4,17 @@
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
#include <stddef.h>
#include <algorithm> #include <algorithm>
#include <memory>
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/test_browser_window.h" #include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#if defined(OS_WIN)
#include "components/metrics/metrics_pref_names.h"
#endif
typedef BrowserWithTestWindowTest BrowserListTest; typedef BrowserWithTestWindowTest BrowserListTest;
...@@ -162,23 +150,3 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) { ...@@ -162,23 +150,3 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) {
browser3->tab_strip_model()->CloseAllTabs(); browser3->tab_strip_model()->CloseAllTabs();
} }
#if defined(OS_CHROMEOS)
// Calling AttemptRestart on ChromeOS will exit the test.
#define MAYBE_AttemptRestart DISABLED_AttemptRestart
#else
#define MAYBE_AttemptRestart AttemptRestart
#endif
TEST_F(BrowserListTest, MAYBE_AttemptRestart) {
ASSERT_TRUE(g_browser_process);
TestingPrefServiceSimple* testing_pref_service =
profile_manager()->local_state()->Get();
EXPECT_FALSE(testing_pref_service->GetBoolean(prefs::kWasRestarted));
chrome::AttemptRestart();
EXPECT_TRUE(testing_pref_service->GetBoolean(prefs::kWasRestarted));
// Cancel the effects of us calling chrome::AttemptRestart. Otherwise tests
// ran after this one will fail.
browser_shutdown::SetTryingToQuit(false);
}
...@@ -3065,6 +3065,7 @@ test("unit_tests") { ...@@ -3065,6 +3065,7 @@ test("unit_tests") {
"../browser/gcm/gcm_profile_service_unittest.cc", "../browser/gcm/gcm_profile_service_unittest.cc",
"../browser/importer/firefox_profile_lock_unittest.cc", "../browser/importer/firefox_profile_lock_unittest.cc",
"../browser/importer/profile_writer_unittest.cc", "../browser/importer/profile_writer_unittest.cc",
"../browser/lifetime/application_lifetime_unittest.cc",
# Media remoting is not supported on Android for now. # Media remoting is not supported on Android for now.
"../browser/media/cast_remoting_connector_unittest.cc", "../browser/media/cast_remoting_connector_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment