#!/usr/bin/python

# Copyright (c) 2010 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 pyauto_functional  # Must be imported before pyauto
import pyauto


class InstantTest(pyauto.PyUITest):
  """TestCase for Omnibox Instant feature."""

  def setUp(self):
    pyauto.PyUITest.setUp(self)
    self.SetPrefs(pyauto.kInstantEnabled, True)

  def _DoneLoading(self):
    info = self.GetInstantInfo()
    return info.get('current') and not info.get('loading')

  def testInstantNavigation(self):
    """Test that instant navigates based on omnibox input."""
    self.SetOmniboxText('google.com')
    self.assertTrue(self.WaitUntil(self._DoneLoading))
    location = self.GetInstantInfo()['location']
    self.assertTrue('google.com' in location)

    self.SetOmniboxText('search.msn.com')
    self.assertTrue(self.WaitUntil(self._DoneLoading))
    location = self.GetInstantInfo()['location']
    self.assertTrue('bing.com' in location)

    # Initiate instant search (at default google.com).
    self.SetOmniboxText('chrome instant')
    self.assertTrue(self.WaitUntil(self._DoneLoading))
    location = self.GetInstantInfo()['location']
    self.assertTrue('google.com' in location)


if __name__ == '__main__':
  pyauto_functional.Main()

@@ -822,32 +822,90 @@
 ('google.com' in
+ location,%0A                    msg='No google.com in %25s' %25
  location)%0A%0A    
@@ -936,11 +936,13 @@
 rch.
-msn
+yahoo
 .com
@@ -1073,20 +1073,92 @@
 ue('
-bing
+search.yahoo.com' in location,%0A                    msg='No search.yahoo
 .com
-'
  in
+ %25s' %25
  loc
@@ -1393,32 +1393,90 @@
 ('google.com' in
+ location,%0A                    msg='No google.com in %25s' %25
  location)%0A%0A%0Aif 

Fix testInstantNavigation