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

Side by Side Diff: chrome/browser/browser_shutdown_browsertest.cc

Issue 2793443003: Removed NOTIFICATION_BROWSER_CLOSING notification (Closed)
Patch Set: Reset g_shutdown_type on close cancel 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/test/histogram_tester.h"
6 #include "chrome/app/chrome_command_ids.h"
7 #include "chrome/browser/browser_shutdown.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h"
14 #include "content/public/browser/notification_service.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 using testing::_;
19 using testing::AtLeast;
20
21 class BrowserShutdownBrowserTest : public InProcessBrowserTest {
22 public:
23 BrowserShutdownBrowserTest() {}
24 ~BrowserShutdownBrowserTest() override {}
25
26 protected:
27 base::HistogramTester histogram_tester_;
28
29 private:
30 DISALLOW_COPY_AND_ASSIGN(BrowserShutdownBrowserTest);
31 };
32
33 class BrowserClosingObserver : public chrome::BrowserListObserver {
34 public:
35 BrowserClosingObserver() {}
36 MOCK_METHOD1(OnBrowserCloseStarted, void(Browser* browser));
37
38 private:
39 DISALLOW_COPY_AND_ASSIGN(BrowserClosingObserver);
40 };
41
42 IN_PROC_BROWSER_TEST_F(BrowserShutdownBrowserTest,
43 PRE_TwoBrowsersShutdownHistograms) {
44 ui_test_utils::NavigateToURL(browser(), GURL("browser://version"));
45 Browser* browser2 = CreateBrowser(browser()->profile());
46 ui_test_utils::NavigateToURL(browser2, GURL("browser://help"));
47
48 BrowserClosingObserver closing_observer;
49 BrowserList::AddObserver(&closing_observer);
50 EXPECT_CALL(closing_observer, OnBrowserCloseStarted(_)).Times(AtLeast(1));
51
52 content::WindowedNotificationObserver terminate_observer(
53 chrome::NOTIFICATION_APP_TERMINATING,
54 content::NotificationService::AllSources());
55 chrome::ExecuteCommand(browser(), IDC_EXIT);
56 terminate_observer.Wait();
57
58 EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
59 EXPECT_TRUE(BrowserList::GetInstance()->empty());
60 EXPECT_EQ(browser_shutdown::GetShutdownType(),
61 browser_shutdown::WINDOW_CLOSE);
62 BrowserList::RemoveObserver(&closing_observer);
63 }
64
65 IN_PROC_BROWSER_TEST_F(BrowserShutdownBrowserTest,
66 TwoBrowsersShutdownHistograms) {
67 histogram_tester_.ExpectUniqueSample("Shutdown.ShutdownType",
68 browser_shutdown::WINDOW_CLOSE, 1);
69 histogram_tester_.ExpectTotalCount("Shutdown.renderers.total", 1);
70 histogram_tester_.ExpectTotalCount("Shutdown.window_close.time2", 1);
71 histogram_tester_.ExpectTotalCount("Shutdown.window_close.time_per_process",
72 1);
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698