javacommons/javaenv/tsrc/src/testjavaenvinfo.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32cmn.h>
       
    19 #include <stdio.h>
       
    20 #include <string>
       
    21 
       
    22 #include "TestHarness.h"
       
    23 #include <javaenvinfo.h>
       
    24 #include "logger.h"
       
    25 
       
    26 using namespace Java;
       
    27 
       
    28 TEST_GROUP(TestJavaEnvInfoAPI)
       
    29 {
       
    30 
       
    31     TEST_SETUP()
       
    32     {
       
    33     }
       
    34     TEST_TEARDOWN()
       
    35     {
       
    36     }
       
    37 };
       
    38 
       
    39 /**
       
    40  * Test JavaEnvInfo::Version() method.
       
    41  *   1. Test version can be read.
       
    42  */
       
    43 TEST(TestJavaEnvInfoAPI, TestVersion)
       
    44 {
       
    45     LOG(EJavaStorage, EInfo, "+TestVersion");
       
    46     TVersion version = JavaEnvInfo::Version();
       
    47 
       
    48     // Version changes across platform release hence cannot exactly checked.
       
    49     CHECK(version.iBuild >= 0);
       
    50     CHECK(version.iMajor >= 0);
       
    51     CHECK(version.iMinor >= 0);
       
    52     LOG(EJavaStorage, EInfo, "-TestVersion");
       
    53 }
       
    54 
       
    55 /**
       
    56  * Test JavaEnvInfo::GetUserAgentHeaderL() method.
       
    57  *   1. Test headers can be read.
       
    58  */
       
    59 TEST(TestJavaEnvInfoAPI, TestGetUserAgentHeaderL)
       
    60 {
       
    61     LOG(EJavaStorage, EInfo, "+TestGetUserAgentHeaderL");
       
    62     std::auto_ptr<HBufC> headerBuf(JavaEnvInfo::GetUserAgentHeaderL());
       
    63 
       
    64     TPtrC headerPtr(headerBuf->Des());
       
    65 
       
    66     // Headers changes across platform release hence cannot exactly checked.
       
    67     CHECK(headerBuf.get() != 0);
       
    68     CHECK(headerPtr.Size() > 0)
       
    69 
       
    70     LOG(EJavaStorage, EInfo, "-TestGetUserAgentHeaderL");
       
    71 }
       
    72 
       
    73 /**
       
    74  * Test JavaEnvInfo::GetPlatformInfoL() method.
       
    75  *   1. Test platform info can be read.
       
    76  */
       
    77 TEST(TestJavaEnvInfoAPI, TestGetPlatformInfoL)
       
    78 {
       
    79     LOG(EJavaStorage, EInfo, "+TestGetPlatformInfoL");
       
    80     std::auto_ptr<HBufC> headerBuf(JavaEnvInfo::GetPlatformInfoL());
       
    81 
       
    82     TPtrC headerPtr(headerBuf->Des());
       
    83 
       
    84     // Info varies across platform releases hence cannot be exactly checked.
       
    85     CHECK(headerBuf.get() != 0);
       
    86     CHECK(headerPtr.Size() > 0)
       
    87 
       
    88     LOG(EJavaStorage, EInfo, "-TestGetPlatformInfoL");
       
    89 }
       
    90