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

Side by Side Diff: chrome/browser/ui/exclusive_access/fullscreen_controller_state_unittest.cc

Issue 1721633002: Added UMA collection for fullscreen / mouse lock bubble re-shows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/test/histogram_tester.h"
6 #include "build/build_config.h" 7 #include "build/build_config.h"
7 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_tabstrip.h" 9 #include "chrome/browser/ui/browser_tabstrip.h"
9 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" 10 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.h" 12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/test/base/browser_with_test_window_test.h" 14 #include "chrome/test/base/browser_with_test_window_test.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 // The FullscreenControllerStateUnitTest unit test suite exhastively tests 20 // The FullscreenControllerStateUnitTest unit test suite exhastively tests
20 // the FullscreenController through all permutations of events. The behavior 21 // the FullscreenController through all permutations of events. The behavior
21 // of the BrowserWindow is mocked via FullscreenControllerTestWindow. 22 // of the BrowserWindow is mocked via FullscreenControllerTestWindow.
22 23
24 namespace {
25
26 const char kFullscreenReshowHistogramName[] =
27 "ExclusiveAccess.FullscreenBubbleReshowsPerSession";
23 28
24 // FullscreenControllerTestWindow ---------------------------------------------- 29 // FullscreenControllerTestWindow ----------------------------------------------
25 30
26 // A BrowserWindow used for testing FullscreenController. The behavior of this 31 // A BrowserWindow used for testing FullscreenController. The behavior of this
27 // mock is verfied manually by running FullscreenControllerStateInteractiveTest. 32 // mock is verfied manually by running FullscreenControllerStateInteractiveTest.
28 class FullscreenControllerTestWindow : public TestBrowserWindow, 33 class FullscreenControllerTestWindow : public TestBrowserWindow,
29 ExclusiveAccessContext { 34 ExclusiveAccessContext {
30 public: 35 public:
31 // Simulate the window state with an enumeration. 36 // Simulate the window state with an enumeration.
32 enum WindowState { 37 enum WindowState {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 void FullscreenControllerTestWindow::HideDownloadShelf() { 244 void FullscreenControllerTestWindow::HideDownloadShelf() {
240 GetDownloadShelf()->Hide(); 245 GetDownloadShelf()->Hide();
241 } 246 }
242 247
243 void FullscreenControllerTestWindow::UpdateExclusiveAccessExitBubbleContent( 248 void FullscreenControllerTestWindow::UpdateExclusiveAccessExitBubbleContent(
244 const GURL& url, 249 const GURL& url,
245 ExclusiveAccessBubbleType bubble_type) {} 250 ExclusiveAccessBubbleType bubble_type) {}
246 251
247 void FullscreenControllerTestWindow::OnExclusiveAccessUserInput() {} 252 void FullscreenControllerTestWindow::OnExclusiveAccessUserInput() {}
248 253
254 } // namespace
255
249 // FullscreenControllerStateUnitTest ------------------------------------------- 256 // FullscreenControllerStateUnitTest -------------------------------------------
250 257
251 // Unit test fixture testing Fullscreen Controller through its states. Most of 258 // Unit test fixture testing Fullscreen Controller through its states. Most of
252 // the test logic comes from FullscreenControllerStateTest. 259 // the test logic comes from FullscreenControllerStateTest.
253 class FullscreenControllerStateUnitTest : public BrowserWithTestWindowTest, 260 class FullscreenControllerStateUnitTest : public BrowserWithTestWindowTest,
254 public FullscreenControllerStateTest { 261 public FullscreenControllerStateTest {
255 public: 262 public:
256 FullscreenControllerStateUnitTest(); 263 FullscreenControllerStateUnitTest();
257 264
258 // FullscreenControllerStateTest: 265 // FullscreenControllerStateTest:
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 window_->ExitFullscreen(); 474 window_->ExitFullscreen();
468 ChangeWindowFullscreenState(); 475 ChangeWindowFullscreenState();
469 EXPECT_EQ(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, 476 EXPECT_EQ(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE,
470 browser() 477 browser()
471 ->exclusive_access_manager() 478 ->exclusive_access_manager()
472 ->GetExclusiveAccessExitBubbleType()); 479 ->GetExclusiveAccessExitBubbleType());
473 } 480 }
474 481
475 // Test that switching tabs takes the browser out of tab fullscreen. 482 // Test that switching tabs takes the browser out of tab fullscreen.
476 TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaSwitchingTab) { 483 TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaSwitchingTab) {
484 base::HistogramTester histogram_tester;
485
477 AddTab(browser(), GURL(url::kAboutBlankURL)); 486 AddTab(browser(), GURL(url::kAboutBlankURL));
478 AddTab(browser(), GURL(url::kAboutBlankURL)); 487 AddTab(browser(), GURL(url::kAboutBlankURL));
479 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); 488 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE));
480 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); 489 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE));
481 ASSERT_TRUE(browser()->window()->IsFullscreen()); 490 ASSERT_TRUE(browser()->window()->IsFullscreen());
491 histogram_tester.ExpectTotalCount(kFullscreenReshowHistogramName, 0);
482 492
483 browser()->tab_strip_model()->SelectNextTab(); 493 browser()->tab_strip_model()->SelectNextTab();
484 ChangeWindowFullscreenState(); 494 ChangeWindowFullscreenState();
485 EXPECT_FALSE(browser()->window()->IsFullscreen()); 495 EXPECT_FALSE(browser()->window()->IsFullscreen());
496
497 // Do a simple test that histograms are being recorded upon exiting the
498 // fullscreen session.
499 histogram_tester.ExpectUniqueSample(kFullscreenReshowHistogramName, 0, 1);
dominickn 2016/02/23 00:05:27 Nit: is there a test that reshows the bubble so yo
Matt Giuca 2016/02/23 02:50:28 No, there isn't. I tried writing some minimal test
dominickn 2016/02/23 03:05:53 Acknowledged.
486 } 500 }
487 501
488 // Test that switching tabs via detaching the active tab (which is in tab 502 // Test that switching tabs via detaching the active tab (which is in tab
489 // fullscreen) takes the browser out of tab fullscreen. This case can 503 // fullscreen) takes the browser out of tab fullscreen. This case can
490 // occur if the user is in both tab fullscreen and immersive browser fullscreen. 504 // occur if the user is in both tab fullscreen and immersive browser fullscreen.
491 TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaDetachingTab) { 505 TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaDetachingTab) {
492 AddTab(browser(), GURL(url::kAboutBlankURL)); 506 AddTab(browser(), GURL(url::kAboutBlankURL));
493 AddTab(browser(), GURL(url::kAboutBlankURL)); 507 AddTab(browser(), GURL(url::kAboutBlankURL));
494 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); 508 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE));
495 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); 509 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE));
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); 899 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab));
886 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab)); 900 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab));
887 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); 901 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending());
888 EXPECT_FALSE(second_browser->exclusive_access_manager() 902 EXPECT_FALSE(second_browser->exclusive_access_manager()
889 ->fullscreen_controller() 903 ->fullscreen_controller()
890 ->IsWindowFullscreenForTabOrPending()); 904 ->IsWindowFullscreenForTabOrPending());
891 905
892 // Required tear-down specific to this test. 906 // Required tear-down specific to this test.
893 second_browser->tab_strip_model()->CloseAllTabs(); 907 second_browser->tab_strip_model()->CloseAllTabs();
894 } 908 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698