nsresult TextEditorTest::RunUnitTest(int32_t *outNumTests, int32_t *outNumTestsFailed)
{
  nsresult result;
  
  NS_ENSURE_TRUE(outNumTests && outNumTestsFailed, NS_ERROR_NULL_POINTER);
  
  *outNumTests = 0;
  *outNumTestsFailed = 0;
  
  result = InitDoc();
  TEST_RESULT(result);
  // shouldn't we just bail on error here?
  
  // insert some simple text
  result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890"));
  TEST_RESULT(result);
  (*outNumTests)++;
  if (NS_FAILED(result))
    ++(*outNumTestsFailed);
  
  // insert some more text
  result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states.  I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham.  Injustice anywhere is a threat to justice everywhere"));
  TEST_RESULT(result);
  (*outNumTests)++;
  if (NS_FAILED(result))
    ++(*outNumTestsFailed);

  result = TestInsertBreak();
  TEST_RESULT(result);
  (*outNumTests)++;
  if (NS_FAILED(result))
    ++(*outNumTestsFailed);

  result = TestTextProperties();
  TEST_RESULT(result);
  (*outNumTests)++;
  if (NS_FAILED(result))
    ++(*outNumTestsFailed);

  // get us back to the original document
  result = mEditor->Undo(12);
  TEST_RESULT(result);

  return result;
}
Exemple #2
0
//
/// CreateDoc creates a document based on the directory path and the specified
/// template. The flags parameter contains one of the document template constants
/// that determines how the document is created.
//
TDocument*
TDocManager::CreateDoc(TDocTemplate* tpl, LPCTSTR path,
                       TDocument* parent, long flags)
{
  if (!tpl) {
    TRACEX(OwlDocView, 0, _T("CreateDoc(): NULL template specified!"));
    return 0;
  }

  // Creation step 0: Inform docmanager that we're about to create a document
  // and allow docmanager to veto
  //
  if (!CreatingDoc(tpl)) {
    TRACEX(OwlDocView, 1, _T("CreateDoc(): Creation vetoed."));
    return 0;
  }

  // Creation step 1: Construct the document, passing in the parent document
  // Put together a dummy parent document if no parent doc was specified in
  // order to allow us to pass in the DocManager pointer hidden in the parent
  // doc
  //
  TDocument* doc;
  if (!parent){
    TDocument td(this);
     doc = tpl->ConstructDoc(&td);
  }
  else
    doc = tpl->ConstructDoc(parent);

  if (!doc) {
    TRACEX(OwlDocView, 0, _T("CreateDoc(): ConstructDoc call failed"));
    return 0;
  }

  // Creation step2: Initialize the document
  //
  doc->SetTemplate(tpl);
  return InitDoc(doc, path, flags);
}
int main( int argc, const char * argv[] )
{
    //g_ledThread = new 

    if ( argc<2 ) {
        printf("usage: cr3 <filename>\n");
        return 1;
    }

    signal(SIGINT,QuitSignalCount);
    signal(SIGTERM,QuitSignalCount);

#ifdef ENABLE_LEDS
    initLeds();
#endif
    //signal(SIGCHLD,WaitSignalChildExit);

    {
#ifdef ENABLE_LEDS
        postLeds( true );
#endif
        int res = InitDoc( (char *)argv[1] );

        if ( !res ) {
            printf("Failed to show file %s\n", argv[1]);
            closeLeds();
            return 2;
        }
#ifdef ENABLE_LEDS
        postLeds( false );
#endif
    }

   if(g_QuitSignalCounter)
   {
      g_QuitSignalCounter=0;
      GrClose();
      printf("INT signal \n");
#ifdef ENABLE_LEDS
      closeLeds();
#endif
      return 0;
   }

   signal(SIGINT,ExceptionExit);
   signal(SIGTERM,ExceptionExit);

    CRLog::info("Entering event loop");
    CRJinkeWindowManager::instance->runEventLoop();
    CRLog::info("Exiting event loop");

#ifdef ENABLE_LEDS
    closeLeds();
#endif

    HyphMan::uninit();
    ldomDocCache::close();
    ShutdownCREngine();

    return 0;
}