<commit_before>#!/usr/bin/python
# Copyright (c) 2011 The Chromium 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 time

import pyauto_functional
import pyauto


class NetflixTest(pyauto.PyUITest):
  """Test case for Netflix player"""

  # Netflix player states
  _is_playing = '4'

  _title_homepage = 'http://movies.netflix.com/WiHome'
  _signout_page = 'https://account.netflix.com/Logout'
  # 30 Rock
  _test_title = 'http://movies.netflix.com/WiPlayer?'+ \
               'movieid=70136124&trkid=2361637&t=30+Rock'

  def tearDown(self):
    self._SignOut()
    pyauto.PyUITest.tearDown(self) 

  def _IsNetflixPluginEnabled(self):
    """Determine Netflix plugin availability and its state"""
    return [x for x in self.GetPluginsInfo().Plugins() \
               if x['name'] == 'Netflix' and x['enabled']]

  def _LoginToNetflix(self):
    """Login to Netflix"""
    credentials = self.GetPrivateInfo()['test_netflix_acct']
    self.NavigateToURL(credentials['login_url'])
    login_js = """
        document.getElementById('email').value='%s';
        document.getElementById('password').value='%s';
        window.domAutomationController.send('ok');
    """ % (credentials['username'], credentials['password'])
    self.assertEqual(self.ExecuteJavascript(login_js), 'ok',
        msg='Failed to set login credentials')
    self.assertTrue(self.SubmitForm('login-form'),
        msg='Login to Netflix failed')
    
  def _HandleInfobars(self):
    """Manage infobars, come up during the test.

    We expect password and Netflix infobars. Processing only Netflix infobar,
    since to start a vidoe, pressing the OK button is a must. We can keep other
    inforbars open."""
    self.WaitForInfobarCount(2)
    tab_info = self.GetBrowserInfo()['windows'][0]['tabs'][0]<commit_msg>Since a single Netflix account is not sufficient for running Netflix tests simultaneously on multiple boards at a time, so adding a Netflix account per board, which will minimize any failures due to limit of max. 2 streaming at a time for a single account. Review URL: http://codereview.chromium.org/8502004<commit_after>#!/usr/bin/python
# Copyright (c) 2011 The Chromium 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 time

import pyauto_functional
import pyauto


class NetflixTest(pyauto.PyUITest):
  """Test case for Netflix player"""

  # Netflix player states
  _is_playing = '4'

  _title_homepage = 'http://movies.netflix.com/WiHome'
  _signout_page = 'https://account.netflix.com/Logout'
  # 30 Rock
  _test_title = 'http://movies.netflix.com/WiPlayer?'+ \
               'movieid=70136124&trkid=2361637&t=30+Rock'

  def tearDown(self):
    self._SignOut()
    pyauto.PyUITest.tearDown(self) 

  def _IsNetflixPluginEnabled(self):
    """Determine Netflix plugin availability and its state"""
    return [x for x in self.GetPluginsInfo().Plugins() \
               if x['name'] == 'Netflix' and x['enabled']]

  def _LoginToNetflix(self):
    """Login to Netflix"""
    credentials = self.GetPrivateInfo()['test_netflix_acct']
    board_name = self.ChromeOSBoard()
    assert credentials.get(board_name), \
           'No netflix credentials for %s' % board_name
    self.NavigateToURL(credentials['login_url'])
    login_js = """
        document.getElementById('email').value='%s';
        document.getElementById('password').value='%s';
        window.domAutomationController.send('ok');
    """ % (credentials[board_name], credentials['password'])
    self.assertEqual(self.ExecuteJavascript(login_js), 'ok',
        msg='Failed to set login credentials')
    self.assertTrue(self.SubmitForm('login-form'),
        msg='Login to Netflix failed')
    
  def _HandleInfobars(self):
    """Manage infobars, come up during the test.

    We expect password and Netflix infobars. Processing only Netflix infobar,
    since to start a vidoe, pressing the OK button is a must. We can keep other
    inforbars open."""
    self.WaitForInfobarCount(2)
    tab_info = self.GetBrowserInfo()['windows'][0]['tabs'][0]
{'fraction_non_alphanumeric': 0.12112541726275632, 'fraction_numerical': 0.014783023366714354, 'mean_word_length': 3.844110854503464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4718143', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1250, 'n_words': 348}