1 // Copyright (c) 2012 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/files/file_path.h" 6 #include "base/path_service.h" 7 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/common/chrome_paths.h" 10 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/ui_test_utils.h" 12 #include "content/public/browser/web_contents.h" 13 #include "content/public/test/browser_test_utils.h" 14 #include "net/base/filename_util.h" 15 16 class CalculatorBrowserTest : public InProcessBrowserTest { 17 }; 18 19 IN_PROC_BROWSER_TEST_F(CalculatorBrowserTest, Model) { 20 base::FilePath test_file; 21 PathService::Get(chrome::DIR_TEST_DATA, &test_file); 22 test_file = test_file.DirName().DirName() 23 .AppendASCII("common").AppendASCII("extensions").AppendASCII("docs") 24 .AppendASCII("examples").AppendASCII("apps").AppendASCII("calculator") 25 .AppendASCII("tests").AppendASCII("automatic.html"); 26 27 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file)); 28 29 bool success; 30 bool executed = content::ExecuteScriptAndExtractBool( 31 browser()->tab_strip_model()->GetActiveWebContents(), 32 "window.domAutomationController.send(window.runTests().success)", 33 &success); 34 35 ASSERT_TRUE(executed); 36 ASSERT_TRUE(success); 37 } 38