blob: 51b1a1fe661350155c51b2442d221f848c775523 [file] [log] [blame]
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging, os
from autotest_lib.client.bin import utils
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros import cros_ui_test, httpd
class desktopui_LoadBigFile(cros_ui_test.UITest):
version = 1
def initialize(self):
super(desktopui_LoadBigFile, self).initialize(creds='$default')
# Create a large file
working_folder = os.path.dirname(os.path.abspath(__file__))
big_file_path = os.path.join(working_folder, 'bigfile.txt')
if os.path.exists(big_file_path):
file_handle = open(big_file_path, 'w')
# Devices with 2GB of RAM can't load a page with a million lines within
# a reasonable amount of time.
multiplier = 1
chromeos_board = self.pyauto.ChromeOSBoard()
if chromeos_board == 'stumpy' or chromeos_board == 'lumpy':
multiplier = 2
for i in xrange(500000 * multiplier):
file_handle.write('large amount of data that is irrelavent.\n')
file_handle.write('End of The Project\n')
self._test_url = 'http://localhost:8000/bigfile.txt'
self._expected_title = 'bigfile.txt'
self._sanity_test_url = 'http://localhost:8000/hello.html'
self._sanity_expected_title = 'Hello World'
self._testServer = httpd.HTTPListener(8000, docroot=self.bindir)
def cleanup(self):
super(desktopui_LoadBigFile, self).cleanup()
def run_once(self):
import pyauto_errors
def _OpenUrl():
tab_title = self.pyauto.GetActiveTabTitle()'Expected tab title: %s. Got: %s' %
(self._sanity_expected_title, tab_title))
return tab_title == self._sanity_expected_title
error.TestError('The sanity tab failed to open %s' %
timeout = 60,
# Currently the ActionTimeoutChanger does not work. Once it works we
# can increase the timeout and keep the size of the file static.
# See bug
# pyauto_timeout_changer = self.pyauto.ActionTimeoutChanger(
# self.pyauto, 240 * 1000)
except pyauto_errors.JSONInterfaceError as e:
raise error.TestError('The big file did not load. Error: %s' %
# del pyauto_timeout_changer
find_results = self.pyauto.FindInPage('End of The Project')
if find_results['match_count'] != 1:
error.TestError('Could not find text at the end of the file. '
'The page did not load correctly.')