Chromium Code Reviews| 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 "chrome/browser/ui/fullscreen/fullscreen_controller_state_test.h" | 5 #include "chrome/browser/ui/fullscreen/fullscreen_controller_state_test.h" |
| 6 | 6 |
| 7 #include <memory.h> | 7 #include <memory.h> |
| 8 | 8 |
| 9 #include <iomanip> | 9 #include <iomanip> |
| 10 #include <iostream> | 10 #include <iostream> |
| 11 | 11 |
| 12 #include "chrome/browser/fullscreen.h" | 12 #include "chrome/browser/fullscreen.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 15 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 16 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" | 16 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "content/public/browser/web_contents.h" | |
| 18 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
| 22 #include "base/mac/mac_util.h" | 23 #include "base/mac/mac_util.h" |
| 23 #endif | 24 #endif |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 bool SupportsMacSystemFullscreen() { | 28 bool SupportsMacSystemFullscreen() { |
| 28 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
| 29 return chrome::mac::SupportsSystemFullscreen(); | 30 return chrome::mac::SupportsSystemFullscreen(); |
| 30 #else | 31 #else |
| 31 return false; | 32 return false; |
| 32 #endif | 33 #endif |
| 33 } | 34 } |
| 34 | 35 |
| 35 } // namespace | 36 } // namespace |
| 36 | 37 |
| 37 FullscreenControllerStateTest::FullscreenControllerStateTest() | 38 FullscreenControllerStateTest::FullscreenControllerStateTest() |
| 38 : state_(STATE_NORMAL), | 39 : state_(STATE_NORMAL), |
| 39 last_notification_received_state_(STATE_NORMAL) { | 40 last_notification_received_state_(STATE_NORMAL) { |
| 40 // Human specified state machine data. | 41 // Human specified state machine data. |
| 41 // For each state, for each event, define the resulting state. | 42 // For each state, for each event, define the resulting state. |
| 42 State transition_table_data[][NUM_EVENTS] = { | 43 State transition_table_data[][NUM_EVENTS] = { |
|
scheib
2014/02/12 01:41:16
I think it prudent to add states and expected outc
miu
2014/02/12 08:25:19
Regarding the additional complexity to FullscreenC
scheib
2014/02/12 18:01:36
The controller unfortunately has several 'orthogon
| |
| 43 { // STATE_NORMAL: | 44 { // STATE_NORMAL: |
| 44 STATE_TO_BROWSER_FULLSCREEN_NO_CHROME, // Event TOGGLE_FULLSCREEN | 45 STATE_TO_BROWSER_FULLSCREEN_NO_CHROME, // Event TOGGLE_FULLSCREEN |
| 45 STATE_TO_BROWSER_FULLSCREEN_WITH_CHROME,// Event TOGGLE_FULLSCREEN_CHROME | 46 STATE_TO_BROWSER_FULLSCREEN_WITH_CHROME,// Event TOGGLE_FULLSCREEN_CHROME |
| 46 STATE_TO_TAB_FULLSCREEN, // Event TAB_FULLSCREEN_TRUE | 47 STATE_TO_TAB_FULLSCREEN, // Event TAB_FULLSCREEN_TRUE |
| 47 STATE_NORMAL, // Event TAB_FULLSCREEN_FALSE | 48 STATE_NORMAL, // Event TAB_FULLSCREEN_FALSE |
| 48 STATE_METRO_SNAP, // Event METRO_SNAP_TRUE | 49 STATE_METRO_SNAP, // Event METRO_SNAP_TRUE |
| 49 STATE_NORMAL, // Event METRO_SNAP_FALSE | 50 STATE_NORMAL, // Event METRO_SNAP_FALSE |
| 50 STATE_NORMAL, // Event BUBBLE_EXIT_LINK | 51 STATE_NORMAL, // Event BUBBLE_EXIT_LINK |
| 51 STATE_NORMAL, // Event BUBBLE_ALLOW | 52 STATE_NORMAL, // Event BUBBLE_ALLOW |
| 52 STATE_NORMAL, // Event BUBBLE_DENY | 53 STATE_NORMAL, // Event BUBBLE_DENY |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 #if defined(OS_MACOSX) | 378 #if defined(OS_MACOSX) |
| 378 if (chrome::mac::SupportsSystemFullscreen()) { | 379 if (chrome::mac::SupportsSystemFullscreen()) { |
| 379 GetFullscreenController()->ToggleFullscreenWithChrome(); | 380 GetFullscreenController()->ToggleFullscreenWithChrome(); |
| 380 break; | 381 break; |
| 381 } | 382 } |
| 382 #endif | 383 #endif |
| 383 NOTREACHED() << GetAndClearDebugLog(); | 384 NOTREACHED() << GetAndClearDebugLog(); |
| 384 break; | 385 break; |
| 385 | 386 |
| 386 case TAB_FULLSCREEN_TRUE: | 387 case TAB_FULLSCREEN_TRUE: |
| 387 GetFullscreenController()->ToggleFullscreenModeForTab( | 388 case TAB_FULLSCREEN_FALSE: { |
| 388 GetBrowser()->tab_strip_model()->GetActiveWebContents(), true); | 389 content::WebContents* const active_tab = |
| 390 GetBrowser()->tab_strip_model()->GetActiveWebContents(); | |
| 391 GetFullscreenController()-> | |
| 392 ToggleFullscreenModeForTab(active_tab, event == TAB_FULLSCREEN_TRUE); | |
| 393 // Activating/Deactivating tab fullscreen on a captured tab should not | |
| 394 // evoke a state change in the browser window. | |
| 395 if (active_tab->GetCapturerCount() > 0) | |
| 396 state_ = source_state; | |
| 389 break; | 397 break; |
| 390 | 398 } |
| 391 case TAB_FULLSCREEN_FALSE: | |
| 392 GetFullscreenController()->ToggleFullscreenModeForTab( | |
| 393 GetBrowser()->tab_strip_model()->GetActiveWebContents(), false); | |
| 394 break; | |
| 395 | 399 |
| 396 case METRO_SNAP_TRUE: | 400 case METRO_SNAP_TRUE: |
| 397 #if defined(OS_WIN) | 401 #if defined(OS_WIN) |
| 398 GetFullscreenController()->SetMetroSnapMode(true); | 402 GetFullscreenController()->SetMetroSnapMode(true); |
| 399 #else | 403 #else |
| 400 NOTREACHED() << GetAndClearDebugLog(); | 404 NOTREACHED() << GetAndClearDebugLog(); |
| 401 #endif | 405 #endif |
| 402 break; | 406 break; |
| 403 | 407 |
| 404 case METRO_SNAP_FALSE: | 408 case METRO_SNAP_FALSE: |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 << std::right << std::setw(2) | 815 << std::right << std::setw(2) |
| 812 << info.distance | 816 << info.distance |
| 813 << " }, // " | 817 << " }, // " |
| 814 << GetStateString(state2) << "\n"; | 818 << GetStateString(state2) << "\n"; |
| 815 } | 819 } |
| 816 output << "},\n"; | 820 output << "},\n"; |
| 817 } | 821 } |
| 818 output << "};"; | 822 output << "};"; |
| 819 return output.str(); | 823 return output.str(); |
| 820 } | 824 } |
| OLD | NEW |