Home | History | Annotate | Download | only in accessibility
      1 // Copyright (c) 2011 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 "base/command_line.h"
      6 #include "base/strings/utf_string_conversions.h"
      7 #include "chrome/browser/extensions/extension_apitest.h"
      8 #include "chrome/browser/infobars/infobar_service.h"
      9 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h"
     10 #include "chrome/browser/ui/browser.h"
     11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
     12 #include "chrome/test/base/test_switches.h"
     13 #include "extensions/common/switches.h"
     14 
     15 // Times out on win asan, http://crbug.com/166026
     16 #if defined(OS_WIN) && defined(ADDRESS_SANITIZER)
     17 #define MAYBE_GetAlertsForTab DISABLED_GetAlertsForTab
     18 #else
     19 #define MAYBE_GetAlertsForTab GetAlertsForTab
     20 #endif
     21 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_GetAlertsForTab) {
     22 #if defined(OS_WIN) && defined(USE_ASH)
     23   // Disable this test in Metro+Ash for now (http://crbug.com/262796).
     24   if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
     25     return;
     26 #endif
     27 
     28   content::WebContents* web_contents =
     29       browser()->tab_strip_model()->GetActiveWebContents();
     30   ASSERT_TRUE(web_contents);
     31   InfoBarService* infobar_service =
     32       InfoBarService::FromWebContents(web_contents);
     33   ASSERT_TRUE(infobar_service);
     34 
     35   const char kAlertMessage[] = "Simple Alert Infobar.";
     36   SimpleAlertInfoBarDelegate::Create(infobar_service,
     37                                      InfoBarDelegate::kNoIconID,
     38                                      ASCIIToUTF16(kAlertMessage), false);
     39   CommandLine::ForCurrentProcess()->AppendSwitch(
     40       extensions::switches::kEnableExperimentalExtensionApis);
     41   ASSERT_TRUE(RunExtensionTest("accessibility/get_alerts_for_tab")) << message_;
     42 }
     43