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

Side by Side Diff: chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc

Issue 12018007: Refactor BrowserWindow fullscreen and presentation on Mac to be consistent with other platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge TOT Created 7 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 | Annotate | Revision Log
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 "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/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.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 "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 #if defined(OS_MACOSX)
20 #include "base/mac/mac_util.h"
21 #endif
22
19 FullscreenControllerStateTest::FullscreenControllerStateTest() 23 FullscreenControllerStateTest::FullscreenControllerStateTest()
20 : state_(STATE_NORMAL), 24 : state_(STATE_NORMAL),
21 reentrant_(false) { 25 reentrant_(false) {
22 // Human specified state machine data. 26 // Human specified state machine data.
23 // For each state, for each event, define the resulting state. 27 // For each state, for each event, define the resulting state.
24 State transition_table_data[][NUM_EVENTS] = { 28 State transition_table_data[][NUM_EVENTS] = {
25 { // STATE_NORMAL: 29 { // STATE_NORMAL:
26 STATE_TO_BROWSER_FULLSCREEN_NO_CHROME, // Event TOGGLE_FULLSCREEN 30 STATE_TO_BROWSER_FULLSCREEN_NO_CHROME, // Event TOGGLE_FULLSCREEN
27 STATE_TO_TAB_FULLSCREEN, // Event TAB_FULLSCREEN_TRUE 31 STATE_TO_TAB_FULLSCREEN, // Event TAB_FULLSCREEN_TRUE
28 STATE_NORMAL, // Event TAB_FULLSCREEN_FALSE 32 STATE_NORMAL, // Event TAB_FULLSCREEN_FALSE
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 290
287 debugging_log_ << " InvokeEvent(" << std::left 291 debugging_log_ << " InvokeEvent(" << std::left
288 << std::setw(MAX_EVENT_NAME_LENGTH) << GetEventString(event) 292 << std::setw(MAX_EVENT_NAME_LENGTH) << GetEventString(event)
289 << ") to " 293 << ") to "
290 << std::setw(MAX_STATE_NAME_LENGTH) << GetStateString(next_state); 294 << std::setw(MAX_STATE_NAME_LENGTH) << GetStateString(next_state);
291 295
292 state_ = next_state; 296 state_ = next_state;
293 297
294 switch (event) { 298 switch (event) {
295 case TOGGLE_FULLSCREEN: 299 case TOGGLE_FULLSCREEN:
300 #if defined(OS_MACOSX)
301 GetFullscreenController()->TogglePresentationMode();
302 #else
296 GetFullscreenController()->ToggleFullscreenMode(); 303 GetFullscreenController()->ToggleFullscreenMode();
304 #endif
297 break; 305 break;
298 case TAB_FULLSCREEN_TRUE: 306 case TAB_FULLSCREEN_TRUE:
299 GetFullscreenController()->ToggleFullscreenModeForTab( 307 GetFullscreenController()->ToggleFullscreenModeForTab(
300 chrome::GetActiveWebContents(GetBrowser()), true); 308 chrome::GetActiveWebContents(GetBrowser()), true);
301 break; 309 break;
302 case TAB_FULLSCREEN_FALSE: 310 case TAB_FULLSCREEN_FALSE:
303 GetFullscreenController()->ToggleFullscreenModeForTab( 311 GetFullscreenController()->ToggleFullscreenModeForTab(
304 chrome::GetActiveWebContents(GetBrowser()), false); 312 chrome::GetActiveWebContents(GetBrowser()), false);
305 break; 313 break;
306 #if defined(OS_WIN) 314 #if defined(OS_WIN)
(...skipping 29 matching lines...) Expand all
336 344
337 VerifyWindowState(); 345 VerifyWindowState();
338 346
339 return true; 347 return true;
340 } 348 }
341 349
342 void FullscreenControllerStateTest::VerifyWindowState() { 350 void FullscreenControllerStateTest::VerifyWindowState() {
343 switch (state_) { 351 switch (state_) {
344 case STATE_NORMAL: 352 case STATE_NORMAL:
345 #if defined(OS_MACOSX) 353 #if defined(OS_MACOSX)
346 EXPECT_FALSE(GetBrowser()->window()->InPresentationMode()) 354 EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithChrome())
355 << GetAndClearDebugLog();
356 EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithoutChrome())
347 << GetAndClearDebugLog(); 357 << GetAndClearDebugLog();
348 #endif 358 #endif
349 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForBrowser()) 359 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForBrowser())
350 << GetAndClearDebugLog(); 360 << GetAndClearDebugLog();
351 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForTabOrPending()) 361 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForTabOrPending())
352 << GetAndClearDebugLog(); 362 << GetAndClearDebugLog();
353 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode()) 363 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode())
354 << GetAndClearDebugLog(); 364 << GetAndClearDebugLog();
355 break; 365 break;
356 case STATE_BROWSER_FULLSCREEN_NO_CHROME: 366 case STATE_BROWSER_FULLSCREEN_NO_CHROME:
357 #if defined(OS_MACOSX) 367 #if defined(OS_MACOSX)
358 EXPECT_FALSE(GetBrowser()->window()->InPresentationMode()) 368 EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithChrome())
369 << GetAndClearDebugLog();
370 EXPECT_TRUE(GetBrowser()->window()->IsFullscreenWithoutChrome())
359 << GetAndClearDebugLog(); 371 << GetAndClearDebugLog();
360 #endif 372 #endif
361 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser()) 373 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser())
362 << GetAndClearDebugLog(); 374 << GetAndClearDebugLog();
363 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForTabOrPending()) 375 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForTabOrPending())
364 << GetAndClearDebugLog(); 376 << GetAndClearDebugLog();
365 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode()) 377 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode())
366 << GetAndClearDebugLog(); 378 << GetAndClearDebugLog();
367 break; 379 break;
368 #if defined(OS_WIN) 380 #if defined(OS_WIN)
369 case STATE_METRO_SNAP: 381 case STATE_METRO_SNAP:
370 // No expectation for InPresentationMode. 382 // http://crbug.com/169138
383 // No expectation for IsFullscreenWithChrome() or
384 // IsFullscreenWithoutChrome()
371 385
372 // TODO(scheib) IsFullscreenForBrowser and IsFullscreenForTabOrPending 386 // TODO(scheib) IsFullscreenForBrowser and IsFullscreenForTabOrPending
373 // are returning true and false in interactive tests with real window. 387 // are returning true and false in interactive tests with real window.
374 // With only a single Metro Snap state in this test framework it isn't 388 // With only a single Metro Snap state in this test framework it isn't
375 // fair to try to have an expectation anyway. 389 // fair to try to have an expectation anyway.
376 // 390 //
377 // No expectation for IsFullscreenForBrowser. 391 // No expectation for IsFullscreenForBrowser.
378 // No expectation for IsFullscreenForTabOrPending. 392 // No expectation for IsFullscreenForTabOrPending.
379 EXPECT_TRUE(GetFullscreenController()->IsInMetroSnapMode()) 393 EXPECT_TRUE(GetFullscreenController()->IsInMetroSnapMode())
380 << GetAndClearDebugLog(); 394 << GetAndClearDebugLog();
381 break; 395 break;
382 #endif 396 #endif
383 case STATE_TAB_FULLSCREEN: 397 case STATE_TAB_FULLSCREEN:
384 #if defined(OS_MACOSX) 398 #if defined(OS_MACOSX)
385 EXPECT_TRUE(GetBrowser()->window()->InPresentationMode()) 399 EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithChrome())
400 << GetAndClearDebugLog();
401 EXPECT_TRUE(GetBrowser()->window()->IsFullscreenWithoutChrome())
386 << GetAndClearDebugLog(); 402 << GetAndClearDebugLog();
387 #endif 403 #endif
388 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForBrowser()) 404 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForBrowser())
389 << GetAndClearDebugLog(); 405 << GetAndClearDebugLog();
390 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForTabOrPending()) 406 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForTabOrPending())
391 << GetAndClearDebugLog(); 407 << GetAndClearDebugLog();
392 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode()) 408 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode())
393 << GetAndClearDebugLog(); 409 << GetAndClearDebugLog();
394 break; 410 break;
395 case STATE_TAB_BROWSER_FULLSCREEN: 411 case STATE_TAB_BROWSER_FULLSCREEN:
396 #if defined(OS_MACOSX) 412 #if defined(OS_MACOSX)
397 EXPECT_FALSE(GetBrowser()->window()->InPresentationMode()) 413 EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithChrome())
414 << GetAndClearDebugLog();
415 EXPECT_TRUE(GetBrowser()->window()->IsFullscreenWithoutChrome())
398 << GetAndClearDebugLog(); 416 << GetAndClearDebugLog();
399 #endif 417 #endif
400 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser()) 418 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser())
401 << GetAndClearDebugLog(); 419 << GetAndClearDebugLog();
402 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForTabOrPending()) 420 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForTabOrPending())
403 << GetAndClearDebugLog(); 421 << GetAndClearDebugLog();
404 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode()) 422 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode())
405 << GetAndClearDebugLog(); 423 << GetAndClearDebugLog();
406 break; 424 break;
407 case STATE_TO_NORMAL: 425 case STATE_TO_NORMAL:
408 #if defined(OS_MACOSX) 426 #if defined(OS_MACOSX)
409 EXPECT_FALSE(GetBrowser()->window()->InPresentationMode()) 427 EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithChrome())
428 << GetAndClearDebugLog();
429 EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithoutChrome())
410 << GetAndClearDebugLog(); 430 << GetAndClearDebugLog();
411 #endif 431 #endif
412 // No expectation for IsFullscreenForBrowser. 432 // No expectation for IsFullscreenForBrowser.
413 // No expectation for IsFullscreenForTabOrPending. 433 // No expectation for IsFullscreenForTabOrPending.
414 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode()) 434 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode())
415 << GetAndClearDebugLog(); 435 << GetAndClearDebugLog();
416 break; 436 break;
417 case STATE_TO_BROWSER_FULLSCREEN_NO_CHROME: 437 case STATE_TO_BROWSER_FULLSCREEN_NO_CHROME:
418 #if defined(OS_MACOSX) 438 #if defined(OS_MACOSX)
419 EXPECT_FALSE(GetBrowser()->window()->InPresentationMode()) 439 EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithChrome())
440 << GetAndClearDebugLog();
441 EXPECT_TRUE(GetBrowser()->window()->IsFullscreenWithoutChrome())
420 << GetAndClearDebugLog(); 442 << GetAndClearDebugLog();
421 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser()) 443 EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser())
422 << GetAndClearDebugLog(); 444 << GetAndClearDebugLog();
423 #else 445 #else
424 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForBrowser()) 446 EXPECT_FALSE(GetFullscreenController()->IsFullscreenForBrowser())
425 << GetAndClearDebugLog(); 447 << GetAndClearDebugLog();
426 #endif 448 #endif
427 // No expectation for IsFullscreenForTabOrPending. 449 // No expectation for IsFullscreenForTabOrPending.
428 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode()) 450 EXPECT_FALSE(GetFullscreenController()->IsInMetroSnapMode())
429 << GetAndClearDebugLog(); 451 << GetAndClearDebugLog();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 << GetAndClearDebugLog(); 625 << GetAndClearDebugLog();
604 626
605 debugging_log_ << " Then,\n"; 627 debugging_log_ << " Then,\n";
606 ASSERT_TRUE(InvokeEvent(event)) << GetAndClearDebugLog(); 628 ASSERT_TRUE(InvokeEvent(event)) << GetAndClearDebugLog();
607 } 629 }
608 630
609 FullscreenController* FullscreenControllerStateTest::GetFullscreenController() { 631 FullscreenController* FullscreenControllerStateTest::GetFullscreenController() {
610 return GetBrowser()->fullscreen_controller(); 632 return GetBrowser()->fullscreen_controller();
611 } 633 }
612 634
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698