@@ -98,7 +98,7 @@ define(function (require, exports, module) {
9898 runs ( function ( ) {
9999 var curDoc = DocumentManager . getCurrentDocument ( ) ;
100100 localText = curDoc . getText ( ) ;
101- localText += "\n .testClass { color:#090; }\n" ;
101+ localText += "\n .testClass { background- color:#090; }\n" ;
102102 curDoc . setText ( localText ) ;
103103 } ) ;
104104
@@ -469,50 +469,50 @@ define(function (require, exports, module) {
469469
470470 this . category = "integration" ;
471471
472- describe ( "CSS Editing" , function ( ) {
473-
474- beforeFirst ( function ( ) {
475- SpecRunnerUtils . createTestWindowAndRun ( this , function ( w ) {
476- testWindow = w ;
477- Dialogs = testWindow . brackets . test . Dialogs ;
478- LiveDevelopment = testWindow . brackets . test . LiveDevelopment ;
479- DOMAgent = testWindow . brackets . test . DOMAgent ;
480- DocumentManager = testWindow . brackets . test . DocumentManager ;
481- CommandManager = testWindow . brackets . test . CommandManager ;
482- Commands = testWindow . brackets . test . Commands ;
483- NativeApp = testWindow . brackets . test . NativeApp ;
484- ProjectManager = testWindow . brackets . test . ProjectManager ;
485- } ) ;
486-
487- SpecRunnerUtils . loadProjectInTestWindow ( testPath ) ;
472+ beforeFirst ( function ( ) {
473+ SpecRunnerUtils . createTestWindowAndRun ( this , function ( w ) {
474+ testWindow = w ;
475+ Dialogs = testWindow . brackets . test . Dialogs ;
476+ LiveDevelopment = testWindow . brackets . test . LiveDevelopment ;
477+ DOMAgent = testWindow . brackets . test . DOMAgent ;
478+ DocumentManager = testWindow . brackets . test . DocumentManager ;
479+ CommandManager = testWindow . brackets . test . CommandManager ;
480+ Commands = testWindow . brackets . test . Commands ;
481+ NativeApp = testWindow . brackets . test . NativeApp ;
482+ ProjectManager = testWindow . brackets . test . ProjectManager ;
488483 } ) ;
489484
490- afterLast ( function ( ) {
491- runs ( function ( ) {
492- testWindow = null ;
493- Dialogs = null ;
494- LiveDevelopment = null ;
495- DOMAgent = null ;
496- DocumentManager = null ;
497- CommandManager = null ;
498- Commands = null ;
499- NativeApp = null ;
500- ProjectManager = null ;
501- SpecRunnerUtils . closeTestWindow ( ) ;
502- } ) ;
503- } ) ;
504-
505- beforeEach ( function ( ) {
506- // verify live dev isn't currently active
507- runs ( function ( ) {
508- expect ( LiveDevelopment . status ) . toBe ( LiveDevelopment . STATUS_INACTIVE ) ;
509- } ) ;
485+ SpecRunnerUtils . loadProjectInTestWindow ( testPath ) ;
486+ } ) ;
487+
488+ afterLast ( function ( ) {
489+ runs ( function ( ) {
490+ testWindow = null ;
491+ Dialogs = null ;
492+ LiveDevelopment = null ;
493+ DOMAgent = null ;
494+ DocumentManager = null ;
495+ CommandManager = null ;
496+ Commands = null ;
497+ NativeApp = null ;
498+ ProjectManager = null ;
499+ SpecRunnerUtils . closeTestWindow ( ) ;
510500 } ) ;
511-
512- afterEach ( function ( ) {
513- waitsForDone ( LiveDevelopment . close ( ) , "Waiting for browser to become inactive" , 10000 ) ;
514- testWindow . closeAllFiles ( ) ;
501+ } ) ;
502+
503+ beforeEach ( function ( ) {
504+ // verify live dev isn't currently active
505+ runs ( function ( ) {
506+ expect ( LiveDevelopment . status ) . toBe ( LiveDevelopment . STATUS_INACTIVE ) ;
515507 } ) ;
508+ } ) ;
509+
510+ afterEach ( function ( ) {
511+ waitsForDone ( LiveDevelopment . close ( ) , "Waiting for browser to become inactive" , 10000 ) ;
512+ testWindow . closeAllFiles ( ) ;
513+ } ) ;
514+
515+ describe ( "CSS Editing" , function ( ) {
516516
517517 it ( "should establish a browser connection for an opened html file" , function ( ) {
518518 //open a file
@@ -571,7 +571,7 @@ define(function (require, exports, module) {
571571 runs ( function ( ) {
572572 var curDoc = DocumentManager . getCurrentDocument ( ) ;
573573 localText = curDoc . getText ( ) ;
574- localText += "\n .testClass { color:#090; }\n" ;
574+ localText += "\n .testClass { background- color:#090; }\n" ;
575575 curDoc . setText ( localText ) ;
576576 } ) ;
577577
@@ -614,7 +614,7 @@ define(function (require, exports, module) {
614614 runs ( function ( ) {
615615 var curDoc = DocumentManager . getCurrentDocument ( ) ;
616616 localCssText = curDoc . getText ( ) ;
617- localCssText += "\n .testClass { color:#090; }\n" ;
617+ localCssText += "\n .testClass { background- color:#090; }\n" ;
618618 curDoc . setText ( localCssText ) ;
619619 } ) ;
620620
@@ -642,7 +642,7 @@ define(function (require, exports, module) {
642642 // Verify that we get the modified text in memory and not the original text on disk.
643643 var originalNode ;
644644 runs ( function ( ) {
645- originalNode = DOMAgent . nodeAtLocation ( 396 ) ;
645+ originalNode = DOMAgent . nodeAtLocation ( 414 ) ;
646646 expect ( originalNode . value ) . toBe ( "Live Preview in Brackets is awesome!" ) ;
647647 } ) ;
648648
@@ -672,7 +672,7 @@ define(function (require, exports, module) {
672672 runs ( function ( ) {
673673 testWindow . $ ( LiveDevelopment ) . off ( "statusChange" , statusChangeHandler ) ;
674674
675- updatedNode = DOMAgent . nodeAtLocation ( 396 ) ;
675+ updatedNode = DOMAgent . nodeAtLocation ( 414 ) ;
676676 var liveDoc = LiveDevelopment . getLiveDocForPath ( testPath + "/simple1.css" ) ;
677677
678678 liveDoc . getSourceFromBrowser ( ) . done ( function ( text ) {
@@ -698,6 +698,96 @@ define(function (require, exports, module) {
698698 } ) ;
699699 } ) ;
700700
701+ describe ( "HTML Editing" , function ( ) {
702+
703+ function _openSimpleHTML ( ) {
704+ runs ( function ( ) {
705+ waitsForDone ( SpecRunnerUtils . openProjectFiles ( [ "simple1.html" ] ) , "SpecRunnerUtils.openProjectFiles simple1.html" , 1000 ) ;
706+ } ) ;
707+
708+ openLiveDevelopmentAndWait ( ) ;
709+ }
710+
711+ function _setTextAndCheckStatus ( doc , op , expectedStatus , errorLineNum ) {
712+ var spy = jasmine . createSpy ( ) ;
713+
714+ runs ( function ( ) {
715+ // Install statusChange callback
716+ testWindow . $ ( LiveDevelopment ) . one ( "statusChange" , spy ) ;
717+ op . call ( ) ;
718+ } ) ;
719+
720+ waitsFor ( function ( ) { return spy . callCount > 0 ; } , "statusChange callback" , 1000 ) ;
721+
722+ runs ( function ( ) {
723+ // Verify expected status
724+ expect ( spy . argsForCall [ 0 ] [ 1 ] ) . toEqual ( expectedStatus ) ;
725+
726+ // Check for gutter style
727+ var syncErrorDOM = testWindow . $ ( ".live-preview-sync-error" ) ,
728+ lineNumStr = $ ( syncErrorDOM ) . find ( ".CodeMirror-linenumber" ) . text ( ) ,
729+ lineNum = ( typeof lineNumStr === "string" ) ? parseInt ( lineNumStr , 10 ) : - 1 ;
730+
731+ if ( expectedStatus === LiveDevelopmentModule . STATUS_SYNC_ERROR ) {
732+ expect ( syncErrorDOM . length ) . toEqual ( 1 ) ;
733+ expect ( lineNum ) . toEqual ( errorLineNum ) ;
734+ } else {
735+ expect ( syncErrorDOM . length ) . toEqual ( 0 ) ;
736+ }
737+ } ) ;
738+ }
739+
740+ it ( "should report STATUS_SYNC_ERROR when HTML syntax is invalid" , function ( ) {
741+ var doc ,
742+ originalText ,
743+ text ;
744+
745+ _openSimpleHTML ( ) ;
746+
747+ runs ( function ( ) {
748+ // Create syntax errors
749+ doc = DocumentManager . getCurrentDocument ( ) ;
750+ _setTextAndCheckStatus ( doc , function ( ) {
751+ doc . replaceRange ( "<" , { line : 10 , ch : 2 } ) ;
752+ } , LiveDevelopmentModule . STATUS_SYNC_ERROR , 11 ) ;
753+ } ) ;
754+
755+ runs ( function ( ) {
756+ // Undo syntax errors
757+ _setTextAndCheckStatus ( doc , function ( ) {
758+ testWindow . executeCommand ( Commands . EDIT_UNDO ) ;
759+ } , LiveDevelopmentModule . STATUS_ACTIVE ) ;
760+ } ) ;
761+ } ) ;
762+
763+ it ( "should send edits to the live browser" , function ( ) {
764+ var doc ;
765+
766+ _openSimpleHTML ( ) ;
767+
768+ runs ( function ( ) {
769+ // Spy on RemoteAgent
770+ spyOn ( testWindow . brackets . test . RemoteAgent , "call" ) . andCallThrough ( ) ;
771+
772+ // Create syntax errors
773+ doc = DocumentManager . getCurrentDocument ( ) ;
774+ doc . replaceRange ( "Live Preview in " , { line : 10 , ch : 33 } ) ;
775+ } ) ;
776+
777+ runs ( function ( ) {
778+ var spy = testWindow . brackets . test . RemoteAgent . call ,
779+ args = spy . callCount ? spy . argsForCall [ 0 ] : [ ] ,
780+ edit = args [ 1 ] && args [ 1 ] [ 0 ] ;
781+
782+ expect ( spy . callCount ) . toBe ( 1 ) ;
783+ expect ( args [ 0 ] ) . toEqual ( "applyDOMEdits" ) ;
784+ expect ( edit . type ) . toEqual ( "textReplace" ) ;
785+ expect ( edit . content ) . toEqual ( "Live Preview in Brackets is awesome!" ) ;
786+ } ) ;
787+ } ) ;
788+
789+ } ) ;
790+
701791 } ) ;
702792
703793 describe ( "Servers" , function ( ) {
0 commit comments