Exemplo n.º 1
0
 beforeEach(function () {
     mockEditor = SpecRunnerUtils.createMockEditor(testContent, "json", {
         startLine: 0,
         endLine: 30
     });
     testEditor = mockEditor.editor;
     testDocument = mockEditor.doc;
 });
Exemplo n.º 2
0
 function makeEditorWithRange(range) {
     // create editor with a visible range
     var mocks = SpecRunnerUtils.createMockEditor(defaultContent, "javascript", range);
     myDocument = mocks.doc;
     myEditor = mocks.editor;
     
     myEditor.focus();
 }
Exemplo n.º 3
0
 function setupFullEditor() {
     // create dummy Document and Editor
     var mocks = SpecRunnerUtils.createMockEditor(defaultContent, "javascript");
     myDocument = mocks.doc;
     myEditor = mocks.editor;
     
     myEditor.focus();
 }
Exemplo n.º 4
0
 beforeEach(function () {
     // save original configs
     liveDevelopmentConfig = LiveDevelopmentModule.config;
     inspectorConfig = InspectorModule.config;
     
     // force init
     LiveDevelopmentModule.config = InspectorModule.config = {highlight: true};
     HighlightAgentModule.load();
     
     // module spies
     spyOn(CSSAgentModule, "styleForURL").andReturn("");
     spyOn(CSSAgentModule, "reloadCSSForDocument").andCallFake(function () {});
     spyOn(HighlightAgentModule, "redraw").andCallFake(function () {});
     spyOn(HighlightAgentModule, "rule").andCallFake(function () {});
     InspectorModule.CSS = {
         getStyleSheet   : jasmine.createSpy("getStyleSheet")
     };
     spyOn(LiveDevelopmentModule, "showHighlight").andCallFake(function () {});
     spyOn(LiveDevelopmentModule, "hideHighlight").andCallFake(function () {});
     
     // document spies
     var deferred = new $.Deferred();
     spyOn(CSSDocumentModule.prototype, "getStyleSheetFromBrowser").andCallFake(function () {
         return deferred.promise();
     });
     
     var mock = SpecRunnerUtils.createMockEditor("p {}\n\ndiv {}", "css");
     testDocument = mock.doc;
     testEditor = mock.editor;
     testCSSDoc = new CSSDocumentModule(testDocument, testEditor);
     
     // resolve reloadRules()
     deferred.resolve({rules: [
         {
             selectorText    : "p",
             selectorRange   : {start: 0},
             style           : {range: {end: 3}}
         },
         {
             selectorText    : "div",
             selectorRange   : {start: 6},
             style           : {range: {end: 11}}
         }
     ]});
 });
Exemplo n.º 5
0
        beforeEach(function () {
            var result = SpecRunnerUtils.createMockEditor(docText);
            doc = result.doc;

            gotChange = false;
            gotContentChange = false;
            gotLostSync = false;

            range = new TextRange(doc, 4, 6);
            range.on("change.unittest", function () {
                expect(gotChange).toBe(false);
                gotChange = true;
            }).on("contentChange.unittest", function () {
                expect(gotContentChange).toBe(false);
                gotContentChange = true;
            }).on("lostSync.unittest", function () {
                expect(gotLostSync).toBe(false);
                gotLostSync = true;
            });
        });
Exemplo n.º 6
0
 runs(function () {
     // save original configs
     liveDevelopmentConfig = LiveDevelopmentModule.config;
     inspectorConfig = InspectorModule.config;
     
     // force init
     LiveDevelopmentModule.config = InspectorModule.config = {highlight: true};
     HighlightAgentModule.load();
     
     // module spies -- used to mock actual API calls so that we can test those
     // APIs without having to actually launch the browser.
     spyOn(HighlightAgentModule, "hide").andCallFake(function () {});
     spyOn(HighlightAgentModule, "domElement").andCallFake(function () {});
     
     var mock = SpecRunnerUtils.createMockEditor(fileContent, "html");
     testDocument = mock.doc;
     testEditor = mock.editor;
     
     instrumentedHtml = HTMLInstrumentationModule.generateInstrumentedHTML(testEditor);
     createIdToTagMap(instrumentedHtml);
     testHTMLDoc = new HTMLDocumentModule(testDocument, testEditor);
     testHTMLDoc.setInstrumentationEnabled(true);
 });
Exemplo n.º 7
0
 beforeEach(function () {
     // Normally the editor holder would be created inside a "content" div, which is
     // used in the available height calculation. We create a fake content div just to
     // hold the height, and we'll place the editor holder in it.
     $fakeContentDiv = $("<div class='content'/>")
         .css("height", "200px")
         .appendTo(document.body);
     
     // createMockEditor() creates the mock-editor-holder, and links EditorManager/PanelManager
     // to it (and links PanelManager to our content div)
     var mock = SpecRunnerUtils.createMockEditor("");
     
     // move newly created mock-editor-holder into the content div we created above
     $("#mock-editor-holder")
         .appendTo($fakeContentDiv);
     
     testEditor = mock.editor;
     testDoc = mock.doc;
     $root = $(testEditor.getRootElement());
     
     testDoc._masterEditor = testEditor;
     EditorManager._doShow(testDoc);
 });
Exemplo n.º 8
0
 function createTestEditor(content, languageId) {
     // create dummy Document and Editor
     var mocks = SpecRunnerUtils.createMockEditor(content, languageId);
     myDocument = mocks.doc;
     myEditor = mocks.editor;
 }
 beforeEach(function () {
     // create dummy Document and Editor
     var mocks = SpecRunnerUtils.createMockEditor("hostEditor", "");
     doc = mocks.doc;
     hostEditor = mocks.editor;
 });