Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: chrome/test/remoting/qunit_browser_test_runner.cc

Issue 376803005: JavaScript unit test framework for Chrome remote desktop - Part II (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/remoting/qunit_browser_test_runner.cc
diff --git a/chrome/test/remoting/qunit_browser_test_runner.cc b/chrome/test/remoting/qunit_browser_test_runner.cc
new file mode 100644
index 0000000000000000000000000000000000000000..da3509908e7ef853e03e7ca5c77e674b2c461d1d
--- /dev/null
+++ b/chrome/test/remoting/qunit_browser_test_runner.cc
@@ -0,0 +1,53 @@
+// Copyright 2014 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.
+
+#include "chrome/test/remoting/qunit_browser_test_runner.h"
+
+#include "base/file_util.h"
+#include "base/json/json_reader.h"
+#include "base/values.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/test/browser_test_utils.h"
+#include "net/base/filename_util.h"
+
+void QUnitBrowserTestRunner::QUnitStart(content::WebContents* web_contents) {
+ std::string result;
+
+ // The test suite must include /third_party/qunit/src/browser_test_harness.js
+ // which exposes the entry point browserTestHarness.run().
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ web_contents, "browserTestHarness.run();", &result));
+
+ // Read in the JSON.
+ base::JSONReader reader;
+ scoped_ptr<base::Value> value;
+ value.reset(reader.Read(result, base::JSON_ALLOW_TRAILING_COMMAS));
+
+ // Convert to dictionary.
+ base::DictionaryValue* dict_value = NULL;
+ ASSERT_TRUE(value->GetAsDictionary(&dict_value));
+
+ // Extract the fields.
+ bool passed;
+ ASSERT_TRUE(dict_value->GetBoolean("passed", &passed));
+ std::string error_message;
+ ASSERT_TRUE(dict_value->GetString("errorMessage", &error_message));
+
+ EXPECT_TRUE(passed) << error_message;
+}
+
+void QUnitBrowserTestRunner::RunTest(const base::FilePath& file) {
+ ASSERT_TRUE(PathExists(file)) << "Error: The QUnit test suite <"
+ << file.value() << "> does not exist.";
+ ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(file));
+
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(web_contents);
+
+ std::string result;
+ QUnitStart(web_contents);
+}
« no previous file with comments | « chrome/test/remoting/qunit_browser_test_runner.h ('k') | chrome/test/remoting/webapp_javascript_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698