From ae207fcd3a4fa8996cba5999ba235b12885175e4 Mon Sep 17 00:00:00 2001 From: Serge Gautherie Date: Fri, 10 Dec 2010 04:27:43 +0100 Subject: [PATCH] Bug 369034 - TestTXMgr has error and leaks object; (Ev1) Whitespace cleanup, Var declaration reordering++. r=ehsan a=(test only). DONTBUILD --- editor/txmgr/tests/TestTXMgr.cpp | 75 +++++++++++++++++--------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/editor/txmgr/tests/TestTXMgr.cpp b/editor/txmgr/tests/TestTXMgr.cpp index d768706a39c..7d7afba11ca 100644 --- a/editor/txmgr/tests/TestTXMgr.cpp +++ b/editor/txmgr/tests/TestTXMgr.cpp @@ -439,8 +439,8 @@ class TestTransaction : public nsITransaction { public: - TestTransaction() { } - virtual ~TestTransaction() {} + TestTransaction() {} + virtual ~TestTransaction() {} NS_DECL_ISUPPORTS }; @@ -569,7 +569,7 @@ public: return NS_OK; } - NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge) + NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge) { if (aDidMerge) *aDidMerge = (mFlags & MERGE_FLAG) ? PR_TRUE : PR_FALSE; @@ -784,6 +784,8 @@ reset_globals() nsresult quick_test(TestTransactionFactory *factory) { + nsresult result; + /******************************************************************* * * Create a transaction manager implementation: @@ -792,15 +794,8 @@ quick_test(TestTransactionFactory *factory) printf("Create transaction manager instance ... "); - PRInt32 i, numitems = 0; - nsCOMPtr mgr; - nsITransaction *tx = 0; - TestTransaction *tximpl = 0; - nsITransaction *u1 = 0, *u2 = 0; - nsITransaction *r1 = 0, *r2 = 0; - nsresult result; - - mgr = do_CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, &result); + nsCOMPtr mgr = + do_CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, &result); if (NS_FAILED(result) || !mgr) { printf("ERROR: Failed to create Transaction Manager instance.\n"); return NS_ERROR_OUT_OF_MEMORY; @@ -920,14 +915,14 @@ quick_test(TestTransactionFactory *factory) printf("passed\n"); + PRInt32 numitems; + /******************************************************************* * * Call GetNumberOfUndoItems() with an empty undo stack: * *******************************************************************/ - numitems = 0; - printf("Call GetNumberOfUndoItems() with empty undo stack ... "); result = mgr->GetNumberOfUndoItems(&numitems); @@ -968,6 +963,8 @@ quick_test(TestTransactionFactory *factory) printf("passed\n"); + nsITransaction *tx; + /******************************************************************* * * Call PeekUndoStack() with an empty undo stack: @@ -1052,6 +1049,11 @@ quick_test(TestTransactionFactory *factory) printf("passed\n"); + PRInt32 i; + TestTransaction *tximpl; + nsITransaction *u1, *u2; + nsITransaction *r1, *r2; + /******************************************************************* * * Test coalescing by executing a transaction that can merge any @@ -1496,7 +1498,7 @@ quick_test(TestTransactionFactory *factory) return NS_ERROR_OUT_OF_MEMORY; } - tx = 0; + tx = 0; result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); @@ -1702,7 +1704,7 @@ quick_test(TestTransactionFactory *factory) return NS_ERROR_OUT_OF_MEMORY; } - tx = 0; + tx = 0; result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); @@ -1813,7 +1815,7 @@ quick_test(TestTransactionFactory *factory) return NS_ERROR_OUT_OF_MEMORY; } - tx = 0; + tx = 0; result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); @@ -1931,7 +1933,7 @@ quick_test(TestTransactionFactory *factory) return NS_ERROR_OUT_OF_MEMORY; } - tx = 0; + tx = 0; result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); @@ -1961,7 +1963,7 @@ quick_test(TestTransactionFactory *factory) return NS_ERROR_OUT_OF_MEMORY; } - tx = 0; + tx = 0; result = tximpl->QueryInterface(NS_GET_IID(nsITransaction), (void **)&tx); @@ -2764,6 +2766,8 @@ aggregation_test() nsresult quick_batch_test(TestTransactionFactory *factory) { + nsresult result; + /******************************************************************* * * Create a transaction manager implementation: @@ -2772,15 +2776,8 @@ quick_batch_test(TestTransactionFactory *factory) printf("Create transaction manager instance ... "); - PRInt32 i, numitems = 0; - nsCOMPtr mgr; - nsITransaction *tx = 0; - TestTransaction *tximpl = 0; - nsITransaction *u1 = 0, *u2 = 0; - nsITransaction *r1 = 0, *r2 = 0; - nsresult result; - - mgr = do_CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, &result); + nsCOMPtr mgr = + do_CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, &result); if (NS_FAILED(result) || !mgr) { printf("ERROR: Failed to create Transaction Manager instance.\n"); return NS_ERROR_OUT_OF_MEMORY; @@ -2788,6 +2785,8 @@ quick_batch_test(TestTransactionFactory *factory) printf("passed\n"); + PRInt32 numitems; + /******************************************************************* * * Make sure an unbalanced call to EndBatch() with empty undo stack @@ -2902,6 +2901,10 @@ quick_batch_test(TestTransactionFactory *factory) printf("passed\n"); + PRInt32 i; + TestTransaction *tximpl; + nsITransaction *tx; + /******************************************************************* * * Execute 20 transactions. Afterwards, we should have 1 @@ -2980,6 +2983,9 @@ quick_batch_test(TestTransactionFactory *factory) printf("passed\n"); + nsITransaction *u1, *u2; + nsITransaction *r1, *r2; + /******************************************************************* * * Execute 20 transient transactions. Afterwards, we should still @@ -4475,23 +4481,24 @@ stress_test(TestTransactionFactory *factory, PRInt32 iterations) printf("Stress test of %i iterations (may take a while) ... ", iterations); fflush(stdout); + nsresult result; + /******************************************************************* * * Create a transaction manager: * *******************************************************************/ - PRInt32 i, j; - nsCOMPtr mgr; - nsITransaction *tx = 0; - nsresult result; - - mgr = do_CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, &result); + nsCOMPtr mgr = + do_CreateInstance(NS_TRANSACTIONMANAGER_CONTRACTID, &result); if (NS_FAILED(result) || !mgr) { printf("ERROR: Failed to create Transaction Manager instance.\n"); return NS_ERROR_OUT_OF_MEMORY; } + PRInt32 i, j; + nsITransaction *tx; + for (i = 1; i <= iterations; i++) { /******************************************************************* *