OLD | NEW |
---|---|
(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 }; | |
sky
2017/03/31 14:23:41
private: DISALLOW_..
Alexey Seren
2017/04/02 12:02:35
Acknowledged.
| |
29 | |
30 class BrowserClosingObserver : public chrome::BrowserListObserver { | |
31 public: | |
32 MOCK_METHOD1(OnBrowserWindowClosing, void(Browser* browser)); | |
33 }; | |
34 | |
35 IN_PROC_BROWSER_TEST_F(BrowserShutdownBrowserTest, | |
36 PRE_TwoBrowsersShutdownHistograms) { | |
37 ui_test_utils::NavigateToURL(browser(), GURL("browser://version")); | |
38 Browser* browser2 = CreateBrowser(browser()->profile()); | |
39 ui_test_utils::NavigateToURL(browser2, GURL("browser://help")); | |
40 | |
41 BrowserClosingObserver closing_observer; | |
42 BrowserList::AddObserver(&closing_observer); | |
43 EXPECT_CALL(closing_observer, OnBrowserWindowClosing(_)).Times(AtLeast(1)); | |
44 | |
45 content::WindowedNotificationObserver terminate_observer( | |
46 chrome::NOTIFICATION_APP_TERMINATING, | |
47 content::NotificationService::AllSources()); | |
48 chrome::ExecuteCommand(browser(), IDC_EXIT); | |
49 terminate_observer.Wait(); | |
50 | |
51 EXPECT_TRUE(browser_shutdown::IsTryingToQuit()); | |
52 EXPECT_TRUE(BrowserList::GetInstance()->empty()); | |
53 EXPECT_EQ(browser_shutdown::GetShutdownType(), | |
54 browser_shutdown::WINDOW_CLOSE); | |
55 BrowserList::RemoveObserver(&closing_observer); | |
56 } | |
57 | |
58 IN_PROC_BROWSER_TEST_F(BrowserShutdownBrowserTest, | |
59 TwoBrowsersShutdownHistograms) { | |
60 histogram_tester_.ExpectUniqueSample("Shutdown.ShutdownType", | |
61 browser_shutdown::WINDOW_CLOSE, 1); | |
62 histogram_tester_.ExpectTotalCount("Shutdown.renderers.total", 1); | |
63 histogram_tester_.ExpectTotalCount("Shutdown.window_close.time2", 1); | |
64 histogram_tester_.ExpectTotalCount("Shutdown.window_close.time_per_process", | |
65 1); | |
66 } | |
OLD | NEW |