Example #1
0
void sd_object::test<2>()
{
    const std::string decoded("random");
    //const std::string encoded("cmFuZG9t\n");
    const std::string streamed("b(6)\"random\"");
    typedef std::vector<U8> buf_t;
    buf_t buf;
    std::copy(
        decoded.begin(),
        decoded.end(),
        std::back_insert_iterator<buf_t>(buf));
    LLSD sd;
    sd = buf;
    std::stringstream str;
    S32 count = LLSDSerialize::toNotation(sd, str);
    ensure_equals("output count", count, 1);
    std::string actual(str.str());
    ensure_equals("formatted binary encoding", actual, streamed);
    sd.clear();
    LLSDSerialize::fromNotation(sd, str, str.str().size());
    std::vector<U8> after;
    after = sd.asBinary();
    ensure_equals("binary decoded size", after.size(), decoded.size());
    ensure("binary decoding", (0 == memcmp(
                                   &after[0],
                                   decoded.c_str(),
                                   decoded.size())));
}
void lllogininstance_object::test<1>()
{
    set_test_name("Test Simple Success And Disconnect");

    // Test default connect.
    logininstance->connect(agentCredential);

    ensure_equals("Default connect uri", gLoginURI, VIEWERLOGIN_URI);

    // Dummy success response.
    LLSD response;
    response["state"] = "online";
    response["change"] = "connect";
    response["progress"] = 1.0;
    response["transfer_rate"] = 7;
    response["data"] = "test_data";

    gTestPump.post(response);

    ensure("Success response", logininstance->authSuccess());
    ensure_equals("Test Response Data", logininstance->getResponse().asString(), "test_data");

    logininstance->disconnect();

    ensure_equals("Called Login Module Disconnect", gDisconnectCalled, true);

    response.clear();
    response["state"] = "offline";
    response["change"] = "disconnect";
    response["progress"] = 0.0;
    response["transfer_rate"] = 0;
    response["data"] = "test_data";

    gTestPump.post(response);

    ensure("Disconnected", !(logininstance->authSuccess()));
}