OLD | NEW |
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" |
| 11 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.h" | 13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_state_test.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/test/base/browser_with_test_window_test.h" | 15 #include "chrome/test/base/browser_with_test_window_test.h" |
14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
15 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 | 20 |
19 // The FullscreenControllerStateUnitTest unit test suite exhastively tests | 21 // The FullscreenControllerStateUnitTest unit test suite exhastively tests |
20 // the FullscreenController through all permutations of events. The behavior | 22 // the FullscreenController through all permutations of events. The behavior |
21 // of the BrowserWindow is mocked via FullscreenControllerTestWindow. | 23 // of the BrowserWindow is mocked via FullscreenControllerTestWindow. |
22 | 24 |
| 25 namespace { |
| 26 |
| 27 const char kFullscreenReshowHistogramName[] = |
| 28 "ExclusiveAccess.BubbleReshowsPerSession.Fullscreen"; |
23 | 29 |
24 // FullscreenControllerTestWindow ---------------------------------------------- | 30 // FullscreenControllerTestWindow ---------------------------------------------- |
25 | 31 |
26 // A BrowserWindow used for testing FullscreenController. The behavior of this | 32 // A BrowserWindow used for testing FullscreenController. The behavior of this |
27 // mock is verfied manually by running FullscreenControllerStateInteractiveTest. | 33 // mock is verfied manually by running FullscreenControllerStateInteractiveTest. |
28 class FullscreenControllerTestWindow : public TestBrowserWindow, | 34 class FullscreenControllerTestWindow : public TestBrowserWindow, |
29 ExclusiveAccessContext { | 35 ExclusiveAccessContext { |
30 public: | 36 public: |
31 // Simulate the window state with an enumeration. | 37 // Simulate the window state with an enumeration. |
32 enum WindowState { | 38 enum WindowState { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 void FullscreenControllerTestWindow::HideDownloadShelf() { | 245 void FullscreenControllerTestWindow::HideDownloadShelf() { |
240 GetDownloadShelf()->Hide(); | 246 GetDownloadShelf()->Hide(); |
241 } | 247 } |
242 | 248 |
243 void FullscreenControllerTestWindow::UpdateExclusiveAccessExitBubbleContent( | 249 void FullscreenControllerTestWindow::UpdateExclusiveAccessExitBubbleContent( |
244 const GURL& url, | 250 const GURL& url, |
245 ExclusiveAccessBubbleType bubble_type) {} | 251 ExclusiveAccessBubbleType bubble_type) {} |
246 | 252 |
247 void FullscreenControllerTestWindow::OnExclusiveAccessUserInput() {} | 253 void FullscreenControllerTestWindow::OnExclusiveAccessUserInput() {} |
248 | 254 |
| 255 } // namespace |
| 256 |
249 // FullscreenControllerStateUnitTest ------------------------------------------- | 257 // FullscreenControllerStateUnitTest ------------------------------------------- |
250 | 258 |
251 // Unit test fixture testing Fullscreen Controller through its states. Most of | 259 // Unit test fixture testing Fullscreen Controller through its states. Most of |
252 // the test logic comes from FullscreenControllerStateTest. | 260 // the test logic comes from FullscreenControllerStateTest. |
253 class FullscreenControllerStateUnitTest : public BrowserWithTestWindowTest, | 261 class FullscreenControllerStateUnitTest : public BrowserWithTestWindowTest, |
254 public FullscreenControllerStateTest { | 262 public FullscreenControllerStateTest { |
255 public: | 263 public: |
256 FullscreenControllerStateUnitTest(); | 264 FullscreenControllerStateUnitTest(); |
257 | 265 |
258 // FullscreenControllerStateTest: | 266 // FullscreenControllerStateTest: |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 window_->ExitFullscreen(); | 475 window_->ExitFullscreen(); |
468 ChangeWindowFullscreenState(); | 476 ChangeWindowFullscreenState(); |
469 EXPECT_EQ(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, | 477 EXPECT_EQ(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, |
470 browser() | 478 browser() |
471 ->exclusive_access_manager() | 479 ->exclusive_access_manager() |
472 ->GetExclusiveAccessExitBubbleType()); | 480 ->GetExclusiveAccessExitBubbleType()); |
473 } | 481 } |
474 | 482 |
475 // Test that switching tabs takes the browser out of tab fullscreen. | 483 // Test that switching tabs takes the browser out of tab fullscreen. |
476 TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaSwitchingTab) { | 484 TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaSwitchingTab) { |
| 485 base::HistogramTester histogram_tester; |
| 486 |
477 AddTab(browser(), GURL(url::kAboutBlankURL)); | 487 AddTab(browser(), GURL(url::kAboutBlankURL)); |
478 AddTab(browser(), GURL(url::kAboutBlankURL)); | 488 AddTab(browser(), GURL(url::kAboutBlankURL)); |
479 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); | 489 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); |
480 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); | 490 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); |
481 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 491 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
| 492 histogram_tester.ExpectTotalCount(kFullscreenReshowHistogramName, 0); |
482 | 493 |
483 browser()->tab_strip_model()->SelectNextTab(); | 494 browser()->tab_strip_model()->SelectNextTab(); |
484 ChangeWindowFullscreenState(); | 495 ChangeWindowFullscreenState(); |
485 EXPECT_FALSE(browser()->window()->IsFullscreen()); | 496 EXPECT_FALSE(browser()->window()->IsFullscreen()); |
| 497 |
| 498 // Do a simple test that histograms are being recorded upon exiting the |
| 499 // fullscreen session (when simplified-fullscreen-ui is enabled). |
| 500 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) |
| 501 histogram_tester.ExpectUniqueSample(kFullscreenReshowHistogramName, 0, 1); |
| 502 else |
| 503 histogram_tester.ExpectTotalCount(kFullscreenReshowHistogramName, 0); |
486 } | 504 } |
487 | 505 |
488 // Test that switching tabs via detaching the active tab (which is in tab | 506 // 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 | 507 // 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. | 508 // occur if the user is in both tab fullscreen and immersive browser fullscreen. |
491 TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaDetachingTab) { | 509 TEST_F(FullscreenControllerStateUnitTest, ExitTabFullscreenViaDetachingTab) { |
492 AddTab(browser(), GURL(url::kAboutBlankURL)); | 510 AddTab(browser(), GURL(url::kAboutBlankURL)); |
493 AddTab(browser(), GURL(url::kAboutBlankURL)); | 511 AddTab(browser(), GURL(url::kAboutBlankURL)); |
494 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); | 512 ASSERT_TRUE(InvokeEvent(TAB_FULLSCREEN_TRUE)); |
495 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); | 513 ASSERT_TRUE(InvokeEvent(WINDOW_CHANGE)); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); | 903 EXPECT_FALSE(wc_delegate->IsFullscreenForTabOrPending(tab)); |
886 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab)); | 904 EXPECT_FALSE(second_wc_delegate->IsFullscreenForTabOrPending(tab)); |
887 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); | 905 EXPECT_FALSE(GetFullscreenController()->IsWindowFullscreenForTabOrPending()); |
888 EXPECT_FALSE(second_browser->exclusive_access_manager() | 906 EXPECT_FALSE(second_browser->exclusive_access_manager() |
889 ->fullscreen_controller() | 907 ->fullscreen_controller() |
890 ->IsWindowFullscreenForTabOrPending()); | 908 ->IsWindowFullscreenForTabOrPending()); |
891 | 909 |
892 // Required tear-down specific to this test. | 910 // Required tear-down specific to this test. |
893 second_browser->tab_strip_model()->CloseAllTabs(); | 911 second_browser->tab_strip_model()->CloseAllTabs(); |
894 } | 912 } |
OLD | NEW |