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

Unified Diff: chrome/browser/browser_shutdown_browsertest.cc

Issue 2793443003: Removed NOTIFICATION_BROWSER_CLOSING notification (Closed)
Patch Set: Added browser tests Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/browser.cc » ('j') | chrome/browser/ui/browser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_shutdown_browsertest.cc
diff --git a/chrome/browser/browser_shutdown_browsertest.cc b/chrome/browser/browser_shutdown_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..19d4302fbfe830585ae8d1c4c48c8719f8a3da24
--- /dev/null
+++ b/chrome/browser/browser_shutdown_browsertest.cc
@@ -0,0 +1,66 @@
+// Copyright 2017 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 "base/test/histogram_tester.h"
+#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/browser_shutdown.h"
+#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/notification_service.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::_;
+using testing::AtLeast;
+
+class BrowserShutdownBrowserTest : public InProcessBrowserTest {
+ public:
+ BrowserShutdownBrowserTest() {}
+ ~BrowserShutdownBrowserTest() override {}
+
+ protected:
+ base::HistogramTester histogram_tester_;
+};
sky 2017/03/31 14:23:41 private: DISALLOW_..
Alexey Seren 2017/04/02 12:02:35 Acknowledged.
+
+class BrowserClosingObserver : public chrome::BrowserListObserver {
+ public:
+ MOCK_METHOD1(OnBrowserWindowClosing, void(Browser* browser));
+};
+
+IN_PROC_BROWSER_TEST_F(BrowserShutdownBrowserTest,
+ PRE_TwoBrowsersShutdownHistograms) {
+ ui_test_utils::NavigateToURL(browser(), GURL("browser://version"));
+ Browser* browser2 = CreateBrowser(browser()->profile());
+ ui_test_utils::NavigateToURL(browser2, GURL("browser://help"));
+
+ BrowserClosingObserver closing_observer;
+ BrowserList::AddObserver(&closing_observer);
+ EXPECT_CALL(closing_observer, OnBrowserWindowClosing(_)).Times(AtLeast(1));
+
+ content::WindowedNotificationObserver terminate_observer(
+ chrome::NOTIFICATION_APP_TERMINATING,
+ content::NotificationService::AllSources());
+ chrome::ExecuteCommand(browser(), IDC_EXIT);
+ terminate_observer.Wait();
+
+ EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
+ EXPECT_EQ(browser_shutdown::GetShutdownType(),
+ browser_shutdown::WINDOW_CLOSE);
+ BrowserList::RemoveObserver(&closing_observer);
+}
+
+IN_PROC_BROWSER_TEST_F(BrowserShutdownBrowserTest,
+ TwoBrowsersShutdownHistograms) {
+ histogram_tester_.ExpectUniqueSample("Shutdown.ShutdownType",
+ browser_shutdown::WINDOW_CLOSE, 1);
+ histogram_tester_.ExpectTotalCount("Shutdown.renderers.total", 1);
+ histogram_tester_.ExpectTotalCount("Shutdown.window_close.time2", 1);
+ histogram_tester_.ExpectTotalCount("Shutdown.window_close.time_per_process",
+ 1);
+}
« no previous file with comments | « no previous file | chrome/browser/ui/browser.cc » ('j') | chrome/browser/ui/browser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698