1#!/usr/bin/env python 2# Copyright (c) 2012 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import pyauto_functional # pyauto_functional must come before pyauto. 7import pyauto 8import test_utils 9 10 11class ChromeosBrowserTest(pyauto.PyUITest): 12 13 def testCannotCloseLastIncognito(self): 14 """Verify that last incognito window cannot be closed if it's the 15 last window""" 16 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) 17 self.assertTrue(self.GetBrowserInfo()['windows'][1]['incognito'], 18 msg='Incognito window is not displayed') 19 20 self.CloseBrowserWindow(0) 21 info = self.GetBrowserInfo()['windows'] 22 self.assertEqual(1, len(info)) 23 url = info[0]['tabs'][0]['url'] 24 self.assertEqual('chrome://newtab/', url, 25 msg='Unexpected URL: %s' % url) 26 self.assertTrue(info[0]['incognito'], 27 msg='Incognito window is not displayed.') 28 29 def testCrashBrowser(self): 30 """Verify that after broswer crash is recovered, user can still navigate 31 to other URL.""" 32 test_utils.CrashBrowser(self) 33 self.RestartBrowser(clear_profile=False) 34 url = self.GetHttpURLForDataPath('english_page.html') 35 self.NavigateToURL(url) 36 self.assertEqual('This page is in English', self.GetActiveTabTitle()) 37 38 def testFullScreen(self): 39 """Verify that a browser window can enter and exit full screen mode.""" 40 self.ApplyAccelerator(pyauto.IDC_FULLSCREEN) 41 self.assertTrue(self.WaitUntil(lambda: 42 self.GetBrowserInfo()['windows'][0]['fullscreen']), 43 msg='Full Screen is not displayed.') 44 45 self.ApplyAccelerator(pyauto.IDC_FULLSCREEN) 46 self.assertTrue(self.WaitUntil(lambda: not 47 self.GetBrowserInfo()['windows'][0]['fullscreen']), 48 msg='Normal screen is not displayed.') 49 50 51if __name__ == '__main__': 52 pyauto_functional.Main() 53