First public contribution.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include <bidivisual.h>
19 #include "TGraphicsContext.h"
20 #include "TBiDiDefect.h"
22 class CTBiDiDefect : public CTGraphicsBase
26 CTBiDiDefect(CTestStep* aStep);
31 virtual void RunTestCaseL(TInt aCurTestCase);
34 void CreateTestGraphicsContextL();
36 void INC016328L(const TDesC& aTestText);
50 void TestDEF021347L(TUint16 aControlCharacter);
51 void TestDEF043720L();
53 void TestPDEF117110L();
56 TBidirectionalState::TRunInfo* iRunInfoArray;
59 CTestGraphicsDevice* iTestGraphicsDevice;
60 CTestGraphicsContext* iTestGraphicsContext;
64 CTBiDiDefect::CTBiDiDefect(CTestStep* aStep) :
65 CTGraphicsBase(aStep),
69 iTestGraphicsDevice(NULL),
70 iTestGraphicsContext(NULL)
74 CTBiDiDefect::~CTBiDiDefect()
76 delete iTestGraphicsContext;
77 delete iTestGraphicsDevice;
80 delete [] iRunInfoArray;
83 void CTBiDiDefect::RunTestCaseL(TInt aCurTestCase)
85 ((CTBiDiDefectStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
91 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0001
93 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0001"));
94 TBuf<32> testText(_L(".Test"));
95 INFO_PRINTF1(_L("INC016328"));
101 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0002
103 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0002"));
104 INFO_PRINTF1(_L("INC016665"));
109 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0003
111 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0003"));
112 INFO_PRINTF1(_L("INC017825"));
117 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0004
119 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0004"));
120 INFO_PRINTF1(_L("INC017974"));
125 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0005
127 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0005"));
128 INFO_PRINTF1(_L("INC017991"));
133 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0006
135 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0006"));
136 INFO_PRINTF1(_L("DEF021227"));
141 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0007
143 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0007"));
144 INFO_PRINTF1(_L("DEF021347"));
149 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0008
151 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0008"));
152 INFO_PRINTF1(_L("INC023337"));
157 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0009
159 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0009"));
160 INFO_PRINTF1(_L("INC023917"));
165 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0010
167 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0010"));
168 INFO_PRINTF1(_L("DEF037928"));
173 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0011
175 //INC037549 TBidiText crashes if <CR><LF> appear at the end of the text
176 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0011"));
177 INFO_PRINTF1(_L("INC037549L"));
182 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0012
184 //INC042422 when calculated length in BidiCompact.cpp TRunInfoCompact::Reorder < 0
185 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0012"));
186 INFO_PRINTF1(_L("INC042422L"));
191 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0013
193 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0013"));
194 INFO_PRINTF1(_L("DEF043720"));
199 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0014
201 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0014"));
202 INFO_PRINTF1(_L("DEF059214: Erroneous caret cursor movements"));
207 @SYMTestCaseID GRAPHICS-GDI-BiDiDefect-0015
209 ((CTBiDiDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-GDI-BiDiDefect-0015"));
210 INFO_PRINTF1(_L("PDEF117110"));
214 ((CTBiDiDefectStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
215 ((CTBiDiDefectStep*)iStep)->CloseTMSGraphicsStep();
219 ((CTBiDiDefectStep*)iStep)->RecordTestResultL();
222 void CTBiDiDefect::CreateTestGraphicsContextL()
224 delete iTestGraphicsContext;
225 iTestGraphicsContext = NULL;
226 delete iTestGraphicsDevice;
227 iTestGraphicsDevice = NULL;
229 TSize windowSize(400, 400);
230 iTestGraphicsDevice = CTestGraphicsDevice::NewL(windowSize);
231 CGraphicsContext* tContext = NULL;
232 TEST(iTestGraphicsDevice->CreateContext(tContext) == KErrNone);
233 iTestGraphicsContext = static_cast<CTestGraphicsContext*>(tContext);
236 //TBidiText crashes if the first character of the text is '.'.
237 void CTBiDiDefect::INC016328L(const TDesC& aTestText)
239 TInt arraySize = TBidirectionalState::GenerateBdRunArray(aTestText.Ptr(), aTestText.Length(), 0, 0);
240 iRunInfoArray = new (ELeave) TBidirectionalState::TRunInfo[arraySize];
241 TBidirectionalState::GenerateBdRunArray(aTestText.Ptr(), aTestText.Length(), iRunInfoArray, arraySize);
242 TBidirectionalState state;
243 state.ReorderLine(iRunInfoArray, arraySize, ETrue, ETrue, EFalse, TChar::EOtherNeutral, TChar::EOtherNeutral);
244 TEST(iRunInfoArray->iLength > 0);
247 //Truncation after space character in Bidirectional text classes.
248 //Actually it doesn't prove missing space character but proves
249 //truncation at the middle of "text" word - yet another defect.
250 void CTBiDiDefect::INC016665L()
252 iTestFont = new (ELeave) CTestFont;
253 iBidiText = TBidiText::NewL(_L("Truncated text"), 1);
254 iBidiText->WrapText(110, *iTestFont, NULL);//"Truncated " and "text"
255 TEST(iBidiText->DisplayText().Length() == 10);
256 TEST(iBidiText->DisplayText()[9] == 0x2026);
259 iBidiText = TBidiText::NewL(_L("Truncated text"), 1);
260 iBidiText->WrapText(110, *iTestFont, NULL);//"Truncated " and "text"
261 TEST(iBidiText->DisplayText().Length() == 10);
262 TEST(iBidiText->DisplayText()[9] == 0x2026);
265 //TBidiText crashes with length 0 descriptor.
266 void CTBiDiDefect::INC017825L()
268 delete iTestGraphicsContext;
269 iTestGraphicsContext = NULL;
270 CreateTestGraphicsContextL();
274 iTestFont = new (ELeave) CTestFont;
278 iBidiText = TBidiText::NewL(KNullDesC(), 1);
279 iBidiText->WrapText(100, *iTestFont, NULL);
281 iBidiText->DrawText(*iTestGraphicsContext, TPoint(0, 20), 20, CGraphicsContext::ERight);
284 //BidiText does not show 0x062A character correctly if it is a first character.
285 void CTBiDiDefect::INC017974L()
287 _LIT(KTextWithLatinLettersFirstArabicLetter, "\x062A abcdef");
291 iTestFont = new (ELeave) CTestFont;
295 iBidiText = TBidiText::NewL(KTextWithLatinLettersFirstArabicLetter, 1);
296 iBidiText->WrapText(100, *iTestFont, NULL);
297 const TText* text = iBidiText->DisplayText().Ptr();
298 TEST(text[7] == 0x062A);//the arabic character should be the first at the end.
301 //TBidiText::DrawText draws out of the area if alignment is right.
302 void CTBiDiDefect::INC017991L()
304 delete iTestGraphicsContext;
305 iTestGraphicsContext = NULL;
306 CreateTestGraphicsContextL();
308 _LIT(KTextWithLatinLetters, "abc def ghijk lmnop qrstuvw xyz 12.34.");
309 const TInt KTextWidth = 200;
313 iTestFont = new (ELeave) CTestFont;
317 iBidiText = TBidiText::NewL(KTextWithLatinLetters, 2);
318 iBidiText->WrapText(KTextWidth, *iTestFont, NULL);
320 iBidiText->DrawText(*iTestGraphicsContext, TPoint(0, 20), 20, CGraphicsContext::ERight);
321 const TTestGCDisplayLine& line1 = iTestGraphicsContext->DisplayLine(0);
322 const TDesC& text1 = line1.iLineData;
323 TInt width1 = iTestFont->TextWidthInPixels(text1);
324 TEST((width1 + line1.iLinePos.iX) <= KTextWidth);
325 const TTestGCDisplayLine& line2 = iTestGraphicsContext->DisplayLine(1);
326 const TDesC& text2 = line2.iLineData;
327 TInt width2 = iTestFont->TextWidthInPixels(text2);
328 TEST((width2 + line2.iLinePos.iX) <= KTextWidth);
331 //TBidiLogicalToVisual seems to lose characters.
332 void CTBiDiDefect::DEF021227()
334 _LIT(KTestText, "Waitnote + D prompt ");
335 // _LIT(KTestText, "Waitnote H D prompt ");
336 TBuf<100> visualText;
337 visualText.Fill(0xCDCD);
338 TBidirectionalState::TRunInfo runArray[6];
340 TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray,
341 sizeof(runArray)/sizeof(runArray[0]));
342 bidiConverter.Reorder();
343 TDesC des = KTestText;
344 bidiConverter.GetVisualLine(visualText, 0, des.Length() - 1, 0xFFFF);
345 TInt len = visualText.Length();
346 TEST((des.Length() - 1) == len);
349 //DrawText should not draw control codes (particularly Bidirectional ones)
350 void CTBiDiDefect::DEF021347L()
352 TestDEF021347L(0x200C);
353 TestDEF021347L(0x200D);
354 TestDEF021347L(0x200E);
355 TestDEF021347L(0x200F);
356 TestDEF021347L(0x202A);
357 TestDEF021347L(0x202B);
358 TestDEF021347L(0x202C);
359 TestDEF021347L(0x202D);
360 TestDEF021347L(0x202E);
361 // Tested in TGLYPHSEL now following rewrite.
362 //TestDEF021347L(0xFFFF);
365 void CTBiDiDefect::TestDEF021347L(TUint16 aControlCharacter)
367 const TInt KTestTextLen = 5;
368 TBuf<100> testText(KTestTextLen);
371 testText[2] = aControlCharacter;
377 iTestFont = new (ELeave) CTestFont;
379 CFont::TPositionParam param;
380 param.iDirection = 0;
382 param.iText.Set(testText);
383 param.iPosInText = 0;
386 param.iPosInText = 2; //testText[2] = aControlCharacter
387 TBool r = iTestFont->GetCharacterPosition(param);
389 TEST(r && param.iPen.iX == 0 && param.iOutputGlyphs == 0);
392 //TBidiLogicalToVisual::GetVisualLine() panics when aEnd == 0
393 void CTBiDiDefect::INC023337()
396 TBuf<100> visualText;
397 visualText.Fill(0xCDCD);
398 TBidirectionalState::TRunInfo runArray[6];
399 TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray, sizeof(runArray)/sizeof(runArray[0]));
400 bidiConverter.Reorder();
402 TDesC des = KTestText;
403 const TUint KEmptyChar = TUint(0xFFFF);
404 //The next statement will panics, if INC023337 is not fixed.
405 bidiConverter.GetVisualLine(visualText, 0, des.Length(), KEmptyChar);
408 //TBidiLogicalToVisual indexes over the given text.
409 void CTBiDiDefect::INC023917()
411 const TInt dest_buf_len = 10;
412 TBidirectionalState::TRunInfo runInfoArray[dest_buf_len];
413 const TInt src_buf_len = 4;
414 TBuf<src_buf_len> logical;
415 logical.Fill(0x0639, src_buf_len);
417 _LIT(KArabicWord, "\x0631\x0641\x0636");
418 logical = KArabicWord;
420 TBidiLogicalToVisual bidiConverter(logical, runInfoArray, sizeof(runInfoArray)/sizeof(runInfoArray[0]));
421 bidiConverter.Reorder();
423 TBuf<dest_buf_len> visual;
424 bidiConverter.GetVisualLine(visual, 0, logical.Length(), 0xFFFF);
426 TEST(visual[0] == 0x0636);
429 // DEF037928 - TBidiLogicalToVisual::GetVisualLine does not work correctly for 0 length strings
430 void CTBiDiDefect::DEF037928()
432 // Zero length string for testing
434 TBuf<100> visualText;
435 visualText.Fill(0xCDCD);
438 TBidirectionalState::TRunInfo runArray[6];
439 TBidiLogicalToVisual bidiConverter(KTestText, EFalse, runArray,
440 sizeof(runArray)/sizeof(runArray[0]));
441 bidiConverter.Reorder();
443 bidiConverter.GetVisualLine(visualText, 0, 1, 0xFFFF);
444 TEST( visualText.Length() == 0);
448 // INC037549 - TBidiText crashes if <CR><LF> appear at the end of the text
449 void CTBiDiDefect::INC037549L()
451 // This crash occured when the final character is <cr>
452 // and following memory location is <lf>
453 // To test this testString has a length of 5, but sPtr has length 4
454 _LIT( testString, "123\r\n" ) ;
455 TBuf<5> string( testString ) ;
456 TPtrC sPtr( string.Ptr(), 4 ) ;
457 TBidiText* bText = TBidiText::NewL( sPtr, 1, TBidiText::ELeftToRight ) ;
462 // INC042422 - when calculated length in BidiCompact.cpp TRunInfoCompact::Reorder < 0
464 // This defect causes an extra blank line to be added when text contains \r\n
465 // This was caused by a miscalculation in Biditext.cpp SizeLineBreak().
466 // this test case is modified due to change of TBidiText::DoWrapText for fixing PDEF117110
467 void CTBiDiDefect::INC042422L()
469 _LIT( testString, "123\r\n" ) ;
470 TBidiText* bText = TBidiText::NewL( testString, 1, TBidiText::ELeftToRight ) ;
471 bText->WrapText(100,*iTestFont,0);
472 TPtrC text = bText->DisplayText();
474 // The defect caused text to contain an extra blank line
475 // So the length was 5 ( text contained:1,2,3, 0x2028, 0x2026)
476 // when the correct value is 4 (text should contain: 1,2,3, 0x2026)
477 // Note: Due to fix for PDEF117109, the correct value is 3 now (text contains: 1,2,3)
478 TEST(text.Length() == 3);
479 TEST(text[0] == '1');
480 TEST(text[1] == '2');
481 TEST(text[2] == '3');
486 //DEF043720 - Assert fails in TBiDiText wrapping when more than one \n is present in the text
487 void CTBiDiDefect::TestDEF043720L()
491 iTestFont = new (ELeave) CTestFont;
495 iBidiText = TBidiText::NewL(_L("\n\nAB\n\n\nCD\n"),10);
496 iBidiText->WrapText(10,*iTestFont,0);
498 //After wrapping text should look like "\x2028\x2028A\x2028B\x2028\x2028\x2028C\x2028D"
499 //where \x2028 is the line separator
500 TPtrC afterwrap(iBidiText->DisplayText());
501 TEST(afterwrap.Length()==11);
502 TEST(afterwrap[0]==0x2028);
503 TEST(afterwrap[1]==0x2028);
504 TEST(afterwrap[3]==0x2028);
505 TEST(afterwrap[5]==0x2028);
506 TEST(afterwrap[6]==0x2028);
507 TEST(afterwrap[7]==0x2028);
508 TEST(afterwrap[9]==0x2028);
510 INFO_PRINTF1(iBidiText->DisplayText());
518 void CTBiDiDefect::DEF059214L()
520 TBidirectionalState::TRunInfo runs[4];
521 TBidirectionalState bs;
524 // entirely left to right paragraph is not ambiguous
527 runs[0].iCategory = TChar::ELeftToRight;
529 runs[0].iLength = 10;
530 bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ELeftToRight,
531 TChar::ELeftToRight, ambig);
533 // entirely right to left paragraph is not ambiguous
536 runs[0].iCategory = TChar::ERightToLeft;
538 runs[0].iLength = 10;
539 bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ERightToLeft,
540 TChar::ERightToLeft, ambig);
543 // right to left portion within left to right paragraph is ambiguous
546 runs[0].iCategory = TChar::ERightToLeft;
548 runs[0].iLength = 10;
549 bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ERightToLeft,
550 TChar::ERightToLeft, ambig);
551 TEST(ambig && ambig != 3000);
554 runs[0].iCategory = TChar::ERightToLeft;
556 runs[0].iLength = 10;
557 bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::EOtherNeutral,
558 TChar::ERightToLeft, ambig);
559 TEST(ambig && ambig != 3000);
561 // left to right portion within right to left paragraph is ambiguous
564 runs[0].iCategory = TChar::ELeftToRight;
566 runs[0].iLength = 10;
567 bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ELeftToRight,
568 TChar::ELeftToRight, ambig);
569 TEST(ambig && ambig != 3000);
572 runs[0].iCategory = TChar::ELeftToRight;
574 runs[0].iLength = 10;
575 bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::EOtherNeutral,
576 TChar::ELeftToRight, ambig);
577 TEST(ambig && ambig != 3000);
579 // right to left following on from left to right paragraph is ambiguous
582 runs[0].iCategory = TChar::ELeftToRight;
584 runs[0].iLength = 10;
585 bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::ERightToLeft,
586 TChar::ERightToLeft, ambig);
587 TEST(ambig && ambig != 3000);
590 runs[0].iCategory = TChar::ELeftToRight;
592 runs[0].iLength = 10;
593 bs.ReorderLine(runs, 1, ETrue, EFalse, EFalse, TChar::EOtherNeutral,
594 TChar::ERightToLeft, ambig);
595 TEST(ambig && ambig != 3000);
597 // left to right following on from right to left paragraph is ambiguous
600 runs[0].iCategory = TChar::ERightToLeft;
602 runs[0].iLength = 10;
603 bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::ELeftToRight,
604 TChar::ELeftToRight, ambig);
605 TEST(ambig && ambig != 3000);
608 runs[0].iCategory = TChar::ERightToLeft;
610 runs[0].iLength = 10;
611 bs.ReorderLine(runs, 1, ETrue, EFalse, ETrue, TChar::EOtherNeutral,
612 TChar::ELeftToRight, ambig);
613 TEST(ambig && ambig != 3000);
616 void CTBiDiDefect::TestPDEF117110L()
622 iTestFont = new (ELeave) CTestFont;
625 iBidiText = TBidiText::NewL(_L("Test Text\n"), 5);
626 iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
627 wrappedText.Set(iBidiText->DisplayText());
628 expectedText.Set(_L("Test Text"));
629 TEST(expectedText.Compare(wrappedText) == 0);
632 iBidiText = TBidiText::NewL(_L("Test Text\r"), 5);
633 iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
634 wrappedText.Set(iBidiText->DisplayText());
635 expectedText.Set(_L("Test Text"));
636 TEST(expectedText.Compare(wrappedText) == 0);
639 iBidiText = TBidiText::NewL(_L("Test Text\r\n"), 5);
640 iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
641 wrappedText.Set(iBidiText->DisplayText());
642 expectedText.Set(_L("Test Text"));
643 TEST(expectedText.Compare(wrappedText) == 0);
646 iBidiText = TBidiText::NewL(_L("Test Text\x2028"), 5);
647 iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
648 wrappedText.Set(iBidiText->DisplayText());
649 expectedText.Set(_L("Test Text"));
650 TEST(expectedText.Compare(wrappedText) == 0);
653 iBidiText = TBidiText::NewL(_L("Test Text\n\x2028"), 5);
654 iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 2);
655 wrappedText.Set(iBidiText->DisplayText());
656 expectedText.Set(_L("Test Text\x2028"));
657 TEST(expectedText.Compare(wrappedText) == 0);
660 iBidiText = TBidiText::NewL(_L("Test\nText\n"), 5);
661 iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 2);
662 wrappedText.Set(iBidiText->DisplayText());
663 expectedText.Set(_L("Test\x2028Text"));
664 TEST(expectedText.Compare(wrappedText) == 0);
667 iBidiText = TBidiText::NewL(_L("Test\nText\n"), 5);
668 iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
669 wrappedText.Set(iBidiText->DisplayText());
670 expectedText.Set(_L("Test\x2026"));
671 TEST(expectedText.Compare(wrappedText) == 0);
674 iBidiText = TBidiText::NewL(_L("TestText\n"), 5);
675 iBidiText->WrapText(45, *iTestFont, NULL, 2);
676 wrappedText.Set(iBidiText->DisplayText());
677 expectedText.Set(_L("Test\x2028Text"));
678 TEST(expectedText.Compare(wrappedText) == 0);
681 iBidiText = TBidiText::NewL(_L("Test Text"), 5);
682 iBidiText->WrapText(KMaxTInt, *iTestFont, NULL, 1);
683 wrappedText.Set(iBidiText->DisplayText());
684 expectedText.Set(_L("Test Text"));
685 TEST(expectedText.Compare(wrappedText) == 0);
694 CTBiDiDefectStep::CTBiDiDefectStep()
696 SetTestStepName(KTBiDiDefectStep);
699 CTGraphicsBase* CTBiDiDefectStep::CreateTestL()
701 return new (ELeave) CTBiDiDefect(this);