1626 //close ss |
1626 //close ss |
1627 CleanupStack::PopAndDestroy(); |
1627 CleanupStack::PopAndDestroy(); |
1628 return TestStepResult(); |
1628 return TestStepResult(); |
1629 } // TE_RConnectionTest318 |
1629 } // TE_RConnectionTest318 |
1630 |
1630 |
|
1631 |
|
1632 /****************************************************************************** |
|
1633 * |
|
1634 * Test TestAllInterfaceNot112 |
|
1635 * |
|
1636 * Added for def143083 |
|
1637 * |
|
1638 * Commsdat configuration should have a default connection that fails to start. |
|
1639 * Uses dummynif and sets it to fail using the mobility pub/sub. |
|
1640 * |
|
1641 * Start listening for AllInterfaceNotification |
|
1642 * Start a connection asynchronously |
|
1643 * On completion of AllInterfaceNotification with EInterfaceUp - Re-request |
|
1644 * Attach another connection to the interface reported as up |
|
1645 * Async start completes with error |
|
1646 * AllInterfaceNotification *SHOULD* complete with EInterfaceDown |
|
1647 *****************************************************************************/ |
|
1648 TVerdict TE_RConnectionTestAllInterfaceNot210::doTestStepL(void) |
|
1649 { |
|
1650 TInt err; |
|
1651 |
|
1652 TRequestStatus allIfaceStatus; |
|
1653 TInterfaceNotificationBuf notificationBuf; |
|
1654 iConnAllIfaceNotify.AllInterfaceNotification(notificationBuf, allIfaceStatus); |
|
1655 |
|
1656 TRequestStatus connStartStatus; |
|
1657 iConnStart.Start(connStartStatus); |
|
1658 User::WaitForRequest(connStartStatus, allIfaceStatus); |
|
1659 |
|
1660 if (allIfaceStatus == KRequestPending) |
|
1661 { |
|
1662 // Fail |
|
1663 INFO_PRINTF2(_L("Connection start completed with %d before AllInterfaceNotification()"), connStartStatus.Int()); |
|
1664 iConnAllIfaceNotify.CancelAllInterfaceNotification(); |
|
1665 User::WaitForRequest(allIfaceStatus); |
|
1666 return EFail; // EFail has no effect, default fail result set in pre-amble |
|
1667 } |
|
1668 |
|
1669 // AllInterfaceNotification() completed |
|
1670 if (notificationBuf().iState != EInterfaceUp) |
|
1671 { |
|
1672 // Fail |
|
1673 INFO_PRINTF1(_L("AllInterfaceNotification() completed with unexpected state [iState != EInterfaceUp]")); |
|
1674 iConnStart.Stop(); |
|
1675 User::WaitForRequest(connStartStatus); |
|
1676 return EFail; // EFail has no effect, default fail result set in pre-amble |
|
1677 } |
|
1678 |
|
1679 INFO_PRINTF1(_L("AllInterfaceNotification() completed with [iState == EInterfaceUp]")); |
|
1680 TConnectionInfoBuf connInfoBuf(notificationBuf().iConnectionInfo); |
|
1681 |
|
1682 // Attach() to the connection |
|
1683 err = iConnAttach.Attach(connInfoBuf, RConnection::EAttachTypeMonitor); |
|
1684 if (err != KErrNone) |
|
1685 { |
|
1686 // FAIL |
|
1687 INFO_PRINTF2(_L("Attach() completed with %d"), err); |
|
1688 iConnStart.Stop(); |
|
1689 User::WaitForRequest(connStartStatus); |
|
1690 return EFail; // EFail has no effect, default fail result set in pre-amble |
|
1691 } |
|
1692 |
|
1693 // Re-request |
|
1694 iConnAllIfaceNotify.AllInterfaceNotification(notificationBuf, allIfaceStatus); |
|
1695 |
|
1696 // Set test time out |
|
1697 TRequestStatus timerStatus; |
|
1698 const TInt KTimerDelay = 20 * 1000 * 1000; // 20 secs should be plenty for the connection start to fail |
|
1699 iTimer.After(timerStatus, KTimerDelay); |
|
1700 |
|
1701 const TInt KRequestCount = 3; |
|
1702 TRequestStatus* requests[KRequestCount] = { &connStartStatus, &allIfaceStatus, &timerStatus }; |
|
1703 User::WaitForNRequest(requests, KRequestCount); |
|
1704 |
|
1705 if (timerStatus != KRequestPending) |
|
1706 { |
|
1707 // Fail |
|
1708 INFO_PRINTF1(_L("Guard timer elapsed")); |
|
1709 iConnAllIfaceNotify.CancelAllInterfaceNotification(); |
|
1710 User::WaitForRequest(allIfaceStatus); |
|
1711 iConnStart.Stop(); |
|
1712 User::WaitForRequest(connStartStatus); |
|
1713 return EFail; // EFail has no effect, default fail result set in pre-amble |
|
1714 } |
|
1715 |
|
1716 iTimer.Cancel(); |
|
1717 User::WaitForRequest(timerStatus); |
|
1718 |
|
1719 if (allIfaceStatus == KRequestPending) |
|
1720 { |
|
1721 // Connection start completed |
|
1722 if (connStartStatus.Int() != KErrNone) |
|
1723 { |
|
1724 // Reset timer and wait a little longer |
|
1725 iTimer.After(timerStatus, KTimerDelay); |
|
1726 User::WaitForRequest(allIfaceStatus, timerStatus); |
|
1727 } |
|
1728 else |
|
1729 { |
|
1730 // FAIL - Misconfigured? Connection is expected to fail |
|
1731 INFO_PRINTF1(_L("Connection started successfully (** Was expected to fail **)")); |
|
1732 iConnAllIfaceNotify.CancelAllInterfaceNotification(); |
|
1733 User::WaitForRequest(allIfaceStatus); |
|
1734 return EFail; // EFail has no effect, default fail result set in pre-amble |
|
1735 } |
|
1736 |
|
1737 if (allIfaceStatus == KRequestPending) |
|
1738 { |
|
1739 // FAIL |
|
1740 INFO_PRINTF1(_L("Guard timer elapsed")); |
|
1741 iConnAllIfaceNotify.CancelAllInterfaceNotification(); |
|
1742 User::WaitForRequest(allIfaceStatus); |
|
1743 return EFail; // EFail has no effect, default fail result set in pre-amble |
|
1744 } |
|
1745 |
|
1746 iTimer.Cancel(); |
|
1747 User::WaitForRequest(timerStatus); |
|
1748 } |
|
1749 else |
|
1750 { |
|
1751 // Just wait for the conn start to complete |
|
1752 User::WaitForRequest(connStartStatus); |
|
1753 if (connStartStatus.Int() == KErrNone) |
|
1754 { |
|
1755 // FAIL - Misconfigured? Connection is expected to fail |
|
1756 INFO_PRINTF1(_L("Connection started successfully (** Was expected to fail **)")); |
|
1757 iConnAllIfaceNotify.CancelAllInterfaceNotification(); |
|
1758 User::WaitForRequest(allIfaceStatus); |
|
1759 return EFail; // EFail has no effect, default fail result set in pre-amble |
|
1760 } |
|
1761 } |
|
1762 |
|
1763 // Last thing to check - make sure it completed with interface down |
|
1764 if (notificationBuf().iState != EInterfaceDown) |
|
1765 { |
|
1766 // FAIL |
|
1767 INFO_PRINTF1(_L("AllInterfaceNotification() completed with unexpected state [iState != EInterfaceDown]")); |
|
1768 return EFail; // EFail has no effect, default fail result set in pre-amble |
|
1769 } |
|
1770 |
|
1771 // PASS |
|
1772 SetTestStepResult(EPass); |
|
1773 } |
|
1774 |
|
1775 TVerdict TE_RConnectionTestAllInterfaceNot210::doTestStepPreambleL() |
|
1776 { |
|
1777 TInt err; |
|
1778 |
|
1779 SetTestStepResult(EFail); |
|
1780 |
|
1781 // Prepare socket server and connections |
|
1782 err = iSS.Connect(); |
|
1783 TESTEL(err == KErrNone, err); |
|
1784 |
|
1785 err = iConnStart.Open(iSS); |
|
1786 TESTEL(err == KErrNone, err); |
|
1787 |
|
1788 err = iConnAttach.Open(iSS); |
|
1789 TESTEL(err == KErrNone, err); |
|
1790 |
|
1791 err = iConnAllIfaceNotify.Open(iSS); |
|
1792 TESTEL(err == KErrNone, err); |
|
1793 |
|
1794 err = iTimer.CreateLocal(); |
|
1795 TESTEL(err == KErrNone, err); |
|
1796 |
|
1797 // Setup the dummynif pub/sub setting |
|
1798 const TUid KAvailabilityTestingPubSubUid = { 0x10272F42 }; |
|
1799 const TInt KApId = 6; /* see the def143083.xml config */ |
|
1800 |
|
1801 RProperty dummyNifEnableProperty; |
|
1802 err = dummyNifEnableProperty.Define(KAvailabilityTestingPubSubUid, KApId , RProperty::EInt); |
|
1803 if (err != KErrAlreadyExists) |
|
1804 { |
|
1805 TESTEL(err == KErrNone, err); |
|
1806 } |
|
1807 |
|
1808 err = dummyNifEnableProperty.Attach(KAvailabilityTestingPubSubUid, KApId); |
|
1809 TESTEL(err == KErrNone, err); |
|
1810 |
|
1811 dummyNifEnableProperty.Set(0); // Dummy NIF not available - Start should fail |
|
1812 dummyNifEnableProperty.Close(); |
|
1813 } |
|
1814 |
|
1815 TVerdict TE_RConnectionTestAllInterfaceNot210::doTestStepPostambleL() |
|
1816 { |
|
1817 |
|
1818 } |
|
1819 |
|
1820 TE_RConnectionTestAllInterfaceNot210::~TE_RConnectionTestAllInterfaceNot210() |
|
1821 { |
|
1822 iConnAllIfaceNotify.Close(); |
|
1823 iConnAttach.Close(); |
|
1824 iConnStart.Close(); |
|
1825 iSS.Close(); |
|
1826 |
|
1827 iTimer.Close(); |
|
1828 } |