浏览代码

Adopt dev-setup in smoketest

Alex Dima 9 年之前
父节点
当前提交
8a31f7f50e
共有 4 个文件被更改,包括 15 次插入79 次删除
  1. 0 31
      test/index-release.html
  2. 2 5
      test/index.html
  3. 4 8
      test/smoketest.html
  4. 9 35
      test/smoketest.js

+ 0 - 31
test/index-release.html

@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
-	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-	<link rel="stylesheet" href="./index.css" />
-</head>
-<body>
-
-<h2>Monaco Editor (running from release)</h2>
-
-<div id="bar" style="margin-bottom: 6px;"></div>
-<div style="clear:both"></div>
-<div id="container" style="float:left;width:800px;height:450px;border: 1px solid grey"></div>
-<div id="options" style="float:left;width:220px;height:450px;border: 1px solid grey"></div>
-<div style="clear:both"></div>
-
-<script src="../release/min/vs/loader.js"></script>
-<script>
-	require.config({
-		paths: {
-			'vs': '../release/min/vs'
-		}
-	});
-	require(['vs/editor/editor.main'], function() {
-		require(['./index'], function() {});
-	});
-</script>
-
-</body>
-</html>

+ 2 - 5
test/index.html

@@ -9,11 +9,8 @@
 
 <h2>Monaco Editor (running from multiple sources)</h2>
 
-<a href="./index.html">[MULTIPLE SOURCES]</a>
-&nbsp;|&nbsp;
-<a href="./index-release.html">[RELEASED]</a>
-&nbsp;|&nbsp;
-<a href="./smoketest-release.html">[SMOKETEST]</a>
+Jump to:
+<a href="./smoketest.html?editor=releaseMin">[SMOKETEST]</a>
 &nbsp;|&nbsp;
 <a href="./mouse-fixed.html">[fixed element]</a>
 &nbsp;|&nbsp;

+ 4 - 8
test/smoketest-release.html → test/smoketest.html

@@ -23,21 +23,17 @@
 </head>
 <body>
 
-<h2>Smoke Test (running from release)</h2>
+<h2>Smoke Test</h2>
 
 <div id="control"></div>
 <div id="editor"></div>
 <div id="errors"></div>
 <div style="clear:both"></div>
 
-<script src="../release/min/vs/loader.js"></script>
+<script src="../metadata.js"></script>
+<script src="dev-setup.js"></script>
 <script>
-	require.config({
-		paths: {
-			'vs': '../release/min/vs'
-		}
-	});
-	require(['vs/editor/editor.main'], function() {
+	loadEditor(function() {
 		require(['./smoketest'], function() {});
 	});
 </script>

+ 9 - 35
test/smoketest.js

@@ -1,5 +1,10 @@
 /// <reference path="../node_modules/monaco-editor-core/monaco.d.ts" />
-define([], function() {
+define(['./samples-all'], function(ALL_SAMPLES) {
+
+var XHR_SAMPLES = {};
+ALL_SAMPLES.forEach(function(sample) {
+	XHR_SAMPLES[sample.name] = sample.content;
+});
 
 var actions = (function() {
 	"use strict";
@@ -88,11 +93,9 @@ function createEditor(container, mode) {
 	editors[mode] = monaco.editor.create(container, {
 		value: mode
 	});
-	xhr('samples/sample.' + mode + '.txt').then(function(response) {
-		var value = mode + '\n' + response.responseText;
-		var model = monaco.editor.createModel(value, mode);
-		editors[mode].setModel(model);
-	});
+	var value = mode + '\n' + XHR_SAMPLES['sample.' + mode + '.txt'];
+	var model = monaco.editor.createModel(value, mode);
+	editors[mode].setModel(model);
 }
 
 function createEditors(modes) {
@@ -133,33 +136,4 @@ function createActions(actions) {
 createEditors(getAllModes());
 createActions(actions);
 
-function xhr(url) {
-	var req = null;
-	return new monaco.Promise(function(c,e,p) {
-		req = new XMLHttpRequest();
-		req.onreadystatechange = function () {
-			if (req._canceled) { return; }
-
-			if (req.readyState === 4) {
-				if ((req.status >= 200 && req.status < 300) || req.status === 1223) {
-					c(req);
-				} else {
-					e(req);
-				}
-				req.onreadystatechange = function () { };
-			} else {
-				p(req);
-			}
-		};
-
-		req.open("GET", url, true );
-		req.responseType = "";
-
-		req.send(null);
-	}, function () {
-		req._canceled = true;
-		req.abort();
-	});
-}
-
 });