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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_unittest.mm

Issue 7740044: Implement fullscreen info bubble on Win and Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix license Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/mac/mac_util.h" 5 #include "base/mac/mac_util.h"
6 #include "base/memory/scoped_nsobject.h" 6 #include "base/memory/scoped_nsobject.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/sync/sync_ui_util.h" 10 #include "chrome/browser/sync/sync_ui_util.h"
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // Check if the window is front most or if one of its child windows (such 682 // Check if the window is front most or if one of its child windows (such
683 // as a status bubble) is front most. 683 // as a status bubble) is front most.
684 static bool IsFrontWindow(NSWindow *window) { 684 static bool IsFrontWindow(NSWindow *window) {
685 NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0]; 685 NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0];
686 return [frontmostWindow isEqual:window] || 686 return [frontmostWindow isEqual:window] ||
687 [[frontmostWindow parentWindow] isEqual:window]; 687 [[frontmostWindow parentWindow] isEqual:window];
688 } 688 }
689 689
690 TEST_F(BrowserWindowFullScreenControllerTest, TestFullscreenNotLion) { 690 TEST_F(BrowserWindowFullScreenControllerTest, TestFullscreenNotLion) {
691 EXPECT_FALSE([controller_ isFullscreen]); 691 EXPECT_FALSE([controller_ isFullscreen]);
692 [controller_ setFullscreen:YES]; 692 [controller_ setFullscreen:YES url:GURL() askPermission:NO];
693 EXPECT_TRUE([controller_ isFullscreen]); 693 EXPECT_TRUE([controller_ isFullscreen]);
694 [controller_ setFullscreen:NO]; 694 [controller_ setFullscreen:NO url:GURL() askPermission:NO];
695 EXPECT_FALSE([controller_ isFullscreen]); 695 EXPECT_FALSE([controller_ isFullscreen]);
696 } 696 }
697 697
698 // If this test fails, it is usually a sign that the bots have some sort of 698 // If this test fails, it is usually a sign that the bots have some sort of
699 // problem (such as a modal dialog up). This tests is a very useful canary, so 699 // problem (such as a modal dialog up). This tests is a very useful canary, so
700 // please do not mark it as flaky without first verifying that there are no bot 700 // please do not mark it as flaky without first verifying that there are no bot
701 // problems. 701 // problems.
702 TEST_F(BrowserWindowFullScreenControllerTest, TestActivateNotLion) { 702 TEST_F(BrowserWindowFullScreenControllerTest, TestActivateNotLion) {
703 EXPECT_FALSE([controller_ isFullscreen]); 703 EXPECT_FALSE([controller_ isFullscreen]);
704 704
705 [controller_ activate]; 705 [controller_ activate];
706 EXPECT_TRUE(IsFrontWindow([controller_ window])); 706 EXPECT_TRUE(IsFrontWindow([controller_ window]));
707 707
708 [controller_ setFullscreen:YES]; 708 [controller_ setFullscreen:YES url:GURL() askPermission:NO];
709 [controller_ activate]; 709 [controller_ activate];
710 EXPECT_TRUE(IsFrontWindow([controller_ createFullscreenWindow])); 710 EXPECT_TRUE(IsFrontWindow([controller_ createFullscreenWindow]));
711 711
712 // We have to cleanup after ourselves by unfullscreening. 712 // We have to cleanup after ourselves by unfullscreening.
713 [controller_ setFullscreen:NO]; 713 [controller_ setFullscreen:NO url:GURL() askPermission:NO];
714 } 714 }
715 715
716 @implementation BrowserWindowControllerFakeFullscreen 716 @implementation BrowserWindowControllerFakeFullscreen
717 // Override |-createFullscreenWindow| to return a dummy window. This isn't 717 // Override |-createFullscreenWindow| to return a dummy window. This isn't
718 // needed to pass the test, but because the dummy window is only 100x100, it 718 // needed to pass the test, but because the dummy window is only 100x100, it
719 // prevents the real fullscreen window from flashing up and taking over the 719 // prevents the real fullscreen window from flashing up and taking over the
720 // whole screen. We have to return an actual window because |-layoutSubviews| 720 // whole screen. We have to return an actual window because |-layoutSubviews|
721 // looks at the window's frame. 721 // looks at the window's frame.
722 - (NSWindow*)createFullscreenWindow { 722 - (NSWindow*)createFullscreenWindow {
723 if (testFullscreenWindow_.get()) 723 if (testFullscreenWindow_.get())
724 return testFullscreenWindow_.get(); 724 return testFullscreenWindow_.get();
725 725
726 testFullscreenWindow_.reset( 726 testFullscreenWindow_.reset(
727 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) 727 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400)
728 styleMask:NSBorderlessWindowMask 728 styleMask:NSBorderlessWindowMask
729 backing:NSBackingStoreBuffered 729 backing:NSBackingStoreBuffered
730 defer:NO]); 730 defer:NO]);
731 return testFullscreenWindow_.get(); 731 return testFullscreenWindow_.get();
732 } 732 }
733 @end 733 @end
734 734
735 /* TODO(???): test other methods of BrowserWindowController */ 735 /* TODO(???): test other methods of BrowserWindowController */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698