Example #1
0
	size_t ut_WiflyControl_FwSetFade_2(void)
	{
		led_cmd expectedOutgoingFrame;
		expectedOutgoingFrame.cmd = SET_FADE;
		expectedOutgoingFrame.data.set_fade.addr[0] = 0x44;
		expectedOutgoingFrame.data.set_fade.addr[1] = 0x33;
		expectedOutgoingFrame.data.set_fade.addr[2] = 0x22;
		expectedOutgoingFrame.data.set_fade.addr[3] = 0x11;
		expectedOutgoingFrame.data.set_fade.red = 0x11;
		expectedOutgoingFrame.data.set_fade.green = 0x22;
		expectedOutgoingFrame.data.set_fade.blue = 0x33;
		expectedOutgoingFrame.data.set_fade.parallelFade = 0x01;
		//TODO why do we use fadeTmms == 1 for SetColor?
		expectedOutgoingFrame.data.set_fade.fadeTmms = htons(1000);

		TestCaseBegin();
		Control testee(0, 0);

		// set color
		testee << FwCmdSetFade {0xff112233, 1000, 0x11223344, true};
		TraceBuffer(ZONE_INFO, &g_SendFrame,           sizeof(cmd_set_fade) + 1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, sizeof(cmd_set_fade) + 1, "%02x ", "SOLL:");
		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, sizeof(cmd_set_fade) + 1));


		TestCaseEnd();
	}
Example #2
0
	size_t ut_WiflyControl_FwSetColorDirectThreeLeds_2(void)
	{
		TestCaseBegin();
		Control testee(0, 0);

		// three leds only, all set to yellow
		const uint32_t argb = 0xffffff00;
		const uint32_t addr = 0x00000007;
		uint8_t shortBuffer[3 * 3];
		memset(shortBuffer, 0, sizeof(shortBuffer));
		shortBuffer[0 * 3 + 0] = 0xff; //first led red
		shortBuffer[1 * 3 + 1] = 0xff; //second led green
		shortBuffer[2 * 3 + 2] = 0xff; //third led blue
		led_cmd expectedOutgoingFrame;
		expectedOutgoingFrame.cmd = SET_COLOR_DIRECT;
		memset(expectedOutgoingFrame.data.set_color_direct.ptr_led_array, 0, 3 * NUM_OF_LED);
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[0] = 0xff;
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[1] = 0xff;
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[2] = 0x00;
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[3] = 0xff;
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[4] = 0xff;
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[5] = 0x00;
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[6] = 0xff;
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[7] = 0xff;
		expectedOutgoingFrame.data.set_color_direct.ptr_led_array[8] = 0x00;

		testee << FwCmdSetColorDirect {argb, addr};


		TraceBuffer(ZONE_INFO, &g_SendFrame,           sizeof(led_cmd) + 1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, sizeof(led_cmd) + 1, "%02x ", "SOLL:");

		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, sizeof(led_cmd)));
		TestCaseEnd();
	}
Example #3
0
	size_t ut_WiflyControl_ConfSetWlan(void)
	{
		TestCaseBegin();
		static const std::string phraseBase("12345678911234567892123456789312345678941234567895123456789612");
		static const std::string phraseContainsNonAlNum(phraseBase + "\x1f");
		static const std::string phrase(phraseBase + "3");
		static const std::string phraseToLong(phrase + " ");
		static const std::string ssid      ("12345678911234567892123456789312");
		static const std::string ssidToLong(ssid + " ");
		Control testee(0, 0);

		// passphrase to short
		CHECK(!testee.ConfSetWlan("", ssid));
		// passphrase to long
		CHECK(!testee.ConfSetWlan(phraseToLong, ssid));

		// passphrase contains not only alphanumeric characters
		CHECK(!testee.ConfSetWlan(phraseContainsNonAlNum, ssid));

		// ssid to short
		CHECK(!testee.ConfSetWlan(phrase, ""));

		// ssid to long
		CHECK(!testee.ConfSetWlan(phrase, ssidToLong));

		// valid passphrase and ssid
		CHECK(testee.ConfSetWlan(phrase, ssid));

		TestCaseEnd();
	}
Example #4
0
	size_t ut_WiflyControl_FwSetRtc(void)
	{
		tm timeinfo;
		time_t rawtime;
		rawtime = time(NULL);
		localtime_r(&rawtime, &timeinfo);

		led_cmd expectedOutgoingFrame = {0xff};
		expectedOutgoingFrame.cmd = SET_RTC;
		expectedOutgoingFrame.data.set_rtc.tm_sec = (uns8) timeinfo.tm_sec;
		expectedOutgoingFrame.data.set_rtc.tm_min = (uns8) timeinfo.tm_min;
		expectedOutgoingFrame.data.set_rtc.tm_hour = (uns8) timeinfo.tm_hour;
		expectedOutgoingFrame.data.set_rtc.tm_mday = (uns8) timeinfo.tm_mday;
		expectedOutgoingFrame.data.set_rtc.tm_mon = (uns8) timeinfo.tm_mon;
		expectedOutgoingFrame.data.set_rtc.tm_year = (uns8) timeinfo.tm_year;
		expectedOutgoingFrame.data.set_rtc.tm_wday = (uns8) timeinfo.tm_wday;


		TestCaseBegin();
		Control testee(0, 0);

		testee << FwCmdSetRtc {timeinfo};
		TraceBuffer(ZONE_INFO, &g_SendFrame,           sizeof(rtc_time) + 1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, sizeof(rtc_time) + 1, "%02x ", "SOLL:");
		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, sizeof(rtc_time) + 1));

		TestCaseEnd();
	}
Example #5
0
	size_t ut_WiflyControl_FwSetGradient(void)
	{
		led_cmd expectedOutgoingFrame;
		expectedOutgoingFrame.cmd = SET_GRADIENT;
		expectedOutgoingFrame.data.set_gradient.red_1 = 0x11;
		expectedOutgoingFrame.data.set_gradient.green_1 = 0x22;
		expectedOutgoingFrame.data.set_gradient.blue_1 = 0x33;
		expectedOutgoingFrame.data.set_gradient.red_2 = 0x33;
		expectedOutgoingFrame.data.set_gradient.green_2 = 0x22;
		expectedOutgoingFrame.data.set_gradient.blue_2 = 0x11;
		expectedOutgoingFrame.data.set_gradient.parallelAndOffset = 0xff;
		expectedOutgoingFrame.data.set_gradient.numberOfLeds = 10;
		expectedOutgoingFrame.data.set_gradient.fadeTmms = htons(1000);

		TestCaseBegin();
		Control testee(0, 0);

		testee << FwCmdSetGradient {0xff112233,0xff332211, 1000, true, 10, 127};
		TraceBuffer(ZONE_INFO, &g_SendFrame,           sizeof(cmd_set_gradient) + 1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, sizeof(cmd_set_gradient) + 1, "%02x ", "SOLL:");
		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, sizeof(cmd_set_gradient) + 1));


		TestCaseEnd();
	}
Example #6
0
	size_t ut_WiflyControl_FwClearScript(void)
	{
		led_cmd expectedOutgoingFrame = {0xff};
		expectedOutgoingFrame.cmd = CLEAR_SCRIPT;

		TestCaseBegin();
		Control testee(0, 0);

		testee << FwCmdClearScript {};
		TraceBuffer(ZONE_INFO, &g_SendFrame,           1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, 1, "%02x ", "SOLL:");
		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, 1));

		TestCaseEnd();
	}
Example #7
0
	size_t ut_WiflyControl_FwSetWait(void)
	{
		led_cmd expectedOutgoingFrame = {0xff};
		expectedOutgoingFrame.cmd = WAIT;
		expectedOutgoingFrame.data.wait.waitTmms = htons(1000);

		TestCaseBegin();
		Control testee(0, 0);

		testee << FwCmdWait {1000};
		TraceBuffer(ZONE_INFO, &g_SendFrame,           sizeof(cmd_wait) + 1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, sizeof(cmd_wait) + 1, "%02x ", "SOLL:");
		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, sizeof(cmd_wait) + 1));

		TestCaseEnd();
	}
Example #8
0
	size_t ut_WiflyControl_FwLoopOn(void)
	{
		led_cmd expectedOutgoingFrame = {0xff};
		expectedOutgoingFrame.cmd = LOOP_ON;

		TestCaseBegin();
		Control testee(0, 0);

		testee << FwCmdLoopOn {};

		TraceBuffer(ZONE_INFO, &g_SendFrame,           1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, 1, "%02x ", "SOLL:");
		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, 1));

		TestCaseEnd();
	}
Example #9
0
void GuiTest::clicking_the_SendMessage_does_not_signal_send_message_when_no_nickname_set()
{
    // arrange
    Ui::ImForm im_form;
    IM::Gui testee(im_form);

    QSignalSpy signal_spy(&testee, SIGNAL(send_message(QString const &)));

    im_form.Nickname->clear();

    // act
    QTest::mouseClick(im_form.SendMessage, Qt::LeftButton);

    // assert
    QCOMPARE(signal_spy.count(), 0);
}
Example #10
0
void GuiTest::clicking_the_AddEvent_does_not_signal_send_event_when_the_input_field_is_empty()
{
    // arrange
    Ui::ImForm im_form;
    IM::Gui testee(im_form);

    QSignalSpy signal_spy(&testee, SIGNAL(send_event(QString const &)));

    im_form.EventInput->clear();

    // act
    QTest::mouseClick(im_form.AddEvent, Qt::LeftButton);

    // assert
    QCOMPARE(signal_spy.count(), 0);
}
Example #11
0
	size_t ut_WiflyControl_FwSetColorDirectToMany(void)
	{
		TestCaseBegin();
		Control testee(0, 0);

		// three leds only, first red, second green last blue
		uint8_t shortBuffer[2 * NUM_OF_LED * 3];
		memset(shortBuffer, 0xff, sizeof(shortBuffer));
		led_cmd expectedOutgoingFrame;
		expectedOutgoingFrame.cmd = SET_COLOR_DIRECT;
		memcpy(expectedOutgoingFrame.data.set_color_direct.ptr_led_array, shortBuffer, NUM_OF_LED * 3);

		testee << FwCmdSetColorDirect(shortBuffer, sizeof(shortBuffer));

		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, sizeof(led_cmd)));
		TestCaseEnd();
	}
Example #12
0
	size_t ut_WiflyControl_FwSetColorDirectRedOnly(void)
	{
		TestCaseBegin();
		Control testee(0, 0);

		// one leds only, first red
		uint8_t shortBuffer[1] {0xff};
		led_cmd expectedOutgoingFrame;
		expectedOutgoingFrame.cmd = SET_COLOR_DIRECT;
		memcpy(expectedOutgoingFrame.data.set_color_direct.ptr_led_array, shortBuffer, sizeof(shortBuffer));
		memset(expectedOutgoingFrame.data.set_color_direct.ptr_led_array + sizeof(shortBuffer), 0x00, sizeof(cmd_set_color_direct) - sizeof(shortBuffer));

		testee << FwCmdSetColorDirect {shortBuffer, sizeof(shortBuffer)};

		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, sizeof(led_cmd)));
		TestCaseEnd();
	}
Example #13
0
	size_t ut_WiflyControl_ConfSetDefaults(void)
	{
		TestCaseBegin();
		static const std::string commands[] = {
			"set broadcast interval 0x1\r\n",    // to support fast broadcast recognition
			"set comm close 0\r\n",            // Disable *CLOS* string
			"set comm open 0\r\n",             // Disable *OPEN* string
			"set comm remote 0\r\n",           // Disable *Hello* string
			"set comm time 5\r\n", 			// Set flush timer to 5 ms
			"set comm idle 240\r\n",			// Set idle timer to 240 s, to close tcp connections after 240s if there's no traffic
			"set dns name rn.microchip.com\r\n",    // set dns of updateserver
			"set ip flags 0x6\r\n",                    // if the module loses the accesspoint connection, the connection is closed
			"set ip dhcp 1\r\n",               // enable DHCP client
			//		"set ftp address 169.254.7.57\r\n",// configure localhost as ftp server in ad-hoc connection
			"set ftp pass Pass123\r\n",        // configure ftp password
			"set ftp user roving\r\n",         // configure ftp username
			"set opt deviceid Wifly_Light\r\n", // Set deviceid which appears in broadcastmsg to "Wifly_Light"
			"set uart baud 115200\r\n",        // PIC uart parameter
			"set uart flow 0\r\n",             // PIC uart parameter
			"set uart mode 0\r\n",             // PIC uart parameter
			"set wlan channel 0\r\n",                  // Set the wlan channel to 0 to perform an automatic scan for a free channel
			"set wlan auth 4\r\n",             // use WPA2 protection
			"set wlan join 1\r\n",             // scan for ap and auto join
			"set wlan rate 0\r\n",             // slowest datarate but highest range
			"set wlan tx 12\r\n",              // Set the Wi-Fi transmit power to maximum
			"set sys printlvl 0\r\n",				// Disables Debug Messages to UART
			"set ip p 11\r\n",                                 // Enable UDP, TCP_CLIENT and TCP Protocol
			//"set sys launch_string wps_app"	   // Choose Wps mode
		};
		static const size_t numCommands = sizeof(commands) / sizeof(commands[0]);

		Control testee(0, 0);

		g_TestBuffer.clear();
			CHECK(testee.ConfSetDefaults());
			CHECK(!g_ProxyConnected);
			CHECK(g_ProxySaved);
			CHECK(numCommands == g_TestBuffer.size());
		for(size_t i = 0; i < numCommands; i++) {
			CHECK(0 == commands[i].compare(g_TestBuffer.front()));
			g_TestBuffer.pop_front();

		}
		TestCaseEnd();
	}
Example #14
0
	size_t ut_WiflyControl_FwGetVersion(void)
	{
		led_cmd expectedOutgoingFrame = {0xff};
		expectedOutgoingFrame.cmd = GET_FW_VERSION;

		TestCaseBegin();
		Control testee(0, 0);

		try {
			testee.FwGetVersion();
		} catch(std::exception) { }

		TraceBuffer(ZONE_INFO, &g_SendFrame,           1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, 1, "%02x ", "SOLL:");
		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, 1));

		TestCaseEnd();
	}
Example #15
0
void GuiTest::clicking_the_SendMessage_clears_the_input_field_is_empty()
{
    // arrange
    Ui::ImForm im_form;
    IM::Gui testee(im_form);

    QSignalSpy signal_spy(&testee, SIGNAL(send_message(QString const &)));

    QString const expected_message = "Hello world.";
    im_form.MessageInput->setText(expected_message);
    im_form.Nickname->setText("Nickname");
    QTest::keyPress(im_form.Nickname, Qt::Key_Enter);
    QTest::keyRelease(im_form.Nickname, Qt::Key_Enter);

    // act
    QTest::mouseClick(im_form.SendMessage, Qt::LeftButton);
    // assert
    QVERIFY(im_form.MessageInput->text().isEmpty());
}
Example #16
0
	size_t ut_WiflyControl_FwLoopOff(void)
	{
		led_cmd expectedOutgoingFrame = {0xff};
		expectedOutgoingFrame.cmd = LOOP_OFF;
		expectedOutgoingFrame.data.loopEnd.numLoops = 100;
		expectedOutgoingFrame.data.loopEnd.counter = 0;
		expectedOutgoingFrame.data.loopEnd.depth = 0;
		expectedOutgoingFrame.data.loopEnd.startIndex = 0;

		TestCaseBegin();
		Control testee(0, 0);

		testee << FwCmdLoopOff {100};

		TraceBuffer(ZONE_INFO, &g_SendFrame,           1, "%02x ", "IS  :");
		TraceBuffer(ZONE_INFO, &expectedOutgoingFrame, 1, "%02x ", "SOLL:");
		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, 1));

		TestCaseEnd();
	}
Example #17
0
	size_t ut_WiflyControl_FwSetColorDirectThreeLeds(void)
	{
		TestCaseBegin();
		Control testee(0, 0);

		// three leds only, first red, second green last blue
		uint8_t shortBuffer[3 * 3];
		memset(shortBuffer, 0, sizeof(shortBuffer));
		shortBuffer[0 * 3 + 0] = 0xff; //first led red
		shortBuffer[1 * 3 + 1] = 0xff; //second led green
		shortBuffer[2 * 3 + 2] = 0xff; //third led blue
		led_cmd expectedOutgoingFrame;
		expectedOutgoingFrame.cmd = SET_COLOR_DIRECT;
		memcpy(expectedOutgoingFrame.data.set_color_direct.ptr_led_array, shortBuffer, sizeof(shortBuffer));
		memset(expectedOutgoingFrame.data.set_color_direct.ptr_led_array + sizeof(shortBuffer), 0x00, sizeof(cmd_set_color_direct) - sizeof(shortBuffer));

		testee << FwCmdSetColorDirect {shortBuffer, sizeof(shortBuffer)};

		CHECK(0 == memcmp(&g_SendFrame, &expectedOutgoingFrame, sizeof(led_cmd)));
		TestCaseEnd();
	}
Example #18
0
void GuiTest::entering_the_Nickname()
{
    // arrange
    Ui::ImForm im_form;
    IM::Gui testee(im_form);

    QSignalSpy signal_spy(&testee, SIGNAL(notify_nickname(QString const &)));

    QString const expected_message = "Nickname";
    im_form.Nickname->setText(expected_message);

    // act
    QTest::keyPress(im_form.Nickname, Qt::Key_Enter);
    QTest::keyRelease(im_form.Nickname, Qt::Key_Enter);

    // assert
    QCOMPARE(signal_spy.count(), 1);

    const auto arguments = signal_spy.takeFirst();
    QCOMPARE(arguments.size(), 1);
    QCOMPARE(arguments.at(0).toString(), expected_message);
}
Example #19
0
int main(int argc, char *argv[])
{
    NS *ns = nsCreate();

    int listen_fd   = nsListen(ns, "localhost", 0);
    int listen_port = netLocalPort(listen_fd);

P   fprintf(stderr, "listen_fd = %d\n", listen_fd);
P   fprintf(stderr, "listen_port = %d\n", listen_port);

    if (fork() == 0) {
        /* Child. */
        nsClose(ns);
        nsDestroy(ns);
        tester(listen_port);
    }
    else {
        /* Parent. */
        testee(ns);
    }

    return errors;
}
Example #20
0
void GuiTest::entering_the_SendMessage_signals_send_message_with_the_message_from_the_input_field()
{
    // arrange
    Ui::ImForm im_form;
    IM::Gui testee(im_form);

    QSignalSpy signal_spy(&testee, SIGNAL(send_message(QString const &)));

    QString const expected_message = "Hello world.";
    im_form.MessageInput->setText(expected_message);
    im_form.Nickname->setText("Nickname");
    QTest::keyPress(im_form.Nickname, Qt::Key_Enter);
    QTest::keyRelease(im_form.Nickname, Qt::Key_Enter);

    // act
    QTest::keyPress(im_form.MessageInput, Qt::Key_Enter);
    QTest::keyRelease(im_form.MessageInput, Qt::Key_Enter);
    // assert
    QCOMPARE(signal_spy.count(), 1);

    const auto arguments = signal_spy.takeFirst();
    QCOMPARE(arguments.size(), 1);
    QCOMPARE(arguments.at(0).toString(), expected_message);
}
Example #21
0
void GuiTest::clicking_the_AddEvent_signals_send_event_with_the_event_from_the_input_field()
{
    // arrange
    Ui::ImForm im_form;
    IM::Gui testee(im_form);

    QSignalSpy signal_spy(&testee, SIGNAL(send_event(QString const &)));

    QString const expected_message = "Hello Event.";
    im_form.EventInput->setText(expected_message);
    im_form.Nickname->setText("Nickname");
    QTest::keyPress(im_form.Nickname, Qt::Key_Enter);
    QTest::keyRelease(im_form.Nickname, Qt::Key_Enter);

    // act
    QTest::mouseClick(im_form.AddEvent, Qt::LeftButton);

    // assert
    QCOMPARE(signal_spy.count(), 1);

    const auto arguments = signal_spy.takeFirst();
    QCOMPARE(arguments.size(), 1);
    QCOMPARE(arguments.at(0).toString(), expected_message);
}
bool OctreeProjectedPolygon::intersects(const BoundingBox& box) const {
    OctreeProjectedPolygon testee(box);
    return intersects(testee);
}
bool OctreeProjectedPolygon::matches(const BoundingBox& box) const {
    OctreeProjectedPolygon testee(box);
    return matches(testee);
}
bool OctreeProjectedPolygon::occludes(const BoundingBox& boxOccludee) const {
    OctreeProjectedPolygon testee(boxOccludee);
    return occludes(testee);
}
void OutputModelTest::benchmarkAddlinesScriptErrorfilter()
{
    OutputModel testee(this);
    testee.setFilteringStrategy(KDevelop::OutputModel::ScriptErrorFilter);
    do_currentBench(testee);
}
void OutputModelTest::benchmarkAddlinesStaticAnalysisfilter()
{
    OutputModel testee(this);
    testee.setFilteringStrategy(KDevelop::OutputModel::StaticAnalysisFilter);
    do_currentBench(testee);
}
bool CubeProjectedPolygon::occludes(const BoundingRectangle& boxOccludee) const {
    CubeProjectedPolygon testee(boxOccludee);
    return occludes(testee);
}
bool CubeProjectedPolygon::matches(const BoundingRectangle& box) const {
    CubeProjectedPolygon testee(box);
    return matches(testee);
}
bool CubeProjectedPolygon::intersects(const BoundingRectangle& box) const {
    CubeProjectedPolygon testee(box);
    return intersects(testee);
}