Home | History | Annotate | Download | only in extensions
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/extensions/extension_apitest.h"
      6 #include "chrome/browser/ui/browser_window.h"
      7 #include "chrome/test/base/ui_test_utils.h"
      8 
      9 // Window resizes are not completed by the time the callback happens,
     10 // so these tests fail on linux/gtk. http://crbug.com/72369
     11 #if defined(OS_LINUX) && !defined(USE_AURA)
     12 #define MAYBE_FocusWindowDoesNotExitFullscreen \
     13   DISABLED_FocusWindowDoesNotExitFullscreen
     14 #define MAYBE_UpdateWindowSizeExitsFullscreen \
     15   DISABLED_UpdateWindowSizeExitsFullscreen
     16 #else
     17 
     18 // TODO(linux_aura) http://crbug.com/163931
     19 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
     20 #define MAYBE_FocusWindowDoesNotExitFullscreen \
     21   DISABLED_FocusWindowDoesNotExitFullscreen
     22 #else
     23 #define MAYBE_FocusWindowDoesNotExitFullscreen FocusWindowDoesNotExitFullscreen
     24 #endif
     25 
     26 #define MAYBE_UpdateWindowSizeExitsFullscreen UpdateWindowSizeExitsFullscreen
     27 #endif  // defined(OS_LINUX) && !defined(USE_AURA)
     28 
     29 IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
     30                        ExtensionFullscreenAccessFail) {
     31   // Test that fullscreen can be accessed from an extension without permission.
     32   ASSERT_TRUE(RunPlatformAppTest("fullscreen/no_permission")) << message_;
     33 }
     34 
     35 // Disabled, a user gesture is required for fullscreen. http://crbug.com/174178
     36 IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
     37                        DISABLED_ExtensionFullscreenAccessPass) {
     38   // Test that fullscreen can be accessed from an extension with permission.
     39   ASSERT_TRUE(RunPlatformAppTest("fullscreen/has_permission")) << message_;
     40 }
     41 
     42 IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
     43                        MAYBE_FocusWindowDoesNotExitFullscreen) {
     44   browser()->window()->EnterFullscreen(
     45       GURL(), FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION);
     46   bool is_fullscreen = browser()->window()->IsFullscreen();
     47   ASSERT_TRUE(RunExtensionTest("window_update/focus")) << message_;
     48   ASSERT_EQ(is_fullscreen, browser()->window()->IsFullscreen());
     49 }
     50 
     51 IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
     52                        MAYBE_UpdateWindowSizeExitsFullscreen) {
     53   browser()->window()->EnterFullscreen(
     54       GURL(), FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION);
     55   ASSERT_TRUE(RunExtensionTest("window_update/sizing")) << message_;
     56   ASSERT_FALSE(browser()->window()->IsFullscreen());
     57 }