os/kernelhwsrv/kerneltest/f32test/server/t_cp_plugin.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// 
sl@0
    15
//
sl@0
    16
//
sl@0
    17
sl@0
    18
sl@0
    19
#include <f32file.h>
sl@0
    20
#include <e32ldr.h>
sl@0
    21
#include <e32ldr_private.h>
sl@0
    22
#include <e32test.h>
sl@0
    23
#include <hal.h>
sl@0
    24
#include "t_server.h"
sl@0
    25
#include "f32dbg.h"
sl@0
    26
sl@0
    27
sl@0
    28
GLDEF_D RTest test(_L("T_CP_PLUGIN"));
sl@0
    29
sl@0
    30
// function decalarations
sl@0
    31
void DoCodePagePluginTest();
sl@0
    32
void TestUnicodeVolumeLabel();
sl@0
    33
void TestShortNameBoundary();
sl@0
    34
void TestConsistentShortNameGeneration();
sl@0
    35
void TestConsistentShortNameExtGeneration();
sl@0
    36
void TestDuplicateLongFileNames();
sl@0
    37
void TestDuplicateLongDirNames();
sl@0
    38
void TestLeadingE5Handling();
sl@0
    39
void TestDEF130334();
sl@0
    40
void TestINC127905();
sl@0
    41
void DeleteTestDirectory();
sl@0
    42
void TestCompatibility();
sl@0
    43
void TestINC126563();
sl@0
    44
sl@0
    45
// Codepage dll name
sl@0
    46
_LIT(KCP932Name,"T_CP932");
sl@0
    47
sl@0
    48
TInt LoadCodePageDll(const TDesC& aCodePageDllName)
sl@0
    49
	{
sl@0
    50
	RDebug::Printf("++ T_CP_PLUGIN.CPP LoadCodePageDll");
sl@0
    51
	
sl@0
    52
	TInt err = KErrNone;
sl@0
    53
	if(aCodePageDllName.Length())
sl@0
    54
		{
sl@0
    55
		RDebug::Print(_L("IS: codepageDllName = %S"), &aCodePageDllName);
sl@0
    56
		RLoader loader;
sl@0
    57
		err = loader.Connect();
sl@0
    58
		if (err==KErrNone)
sl@0
    59
			{
sl@0
    60
			err = loader.SendReceive(ELoadCodePage, TIpcArgs(0, &aCodePageDllName, 0));
sl@0
    61
			RDebug::Printf("\n T_CP_PLUGIN.CPP : LoadCodePageDll : loader.SendReceive == %d", err);
sl@0
    62
			loader.Close();
sl@0
    63
			}
sl@0
    64
		}
sl@0
    65
	RDebug::Printf("-- T_CP_PLUGIN.CPP LoadCodePageDll");
sl@0
    66
	return err;
sl@0
    67
	}
sl@0
    68
sl@0
    69
void DoCodePagePluginTest()
sl@0
    70
	{
sl@0
    71
	RDebug::Printf("++ T_CP_PLUGIN.CPP DoCodePagePluginTestL");
sl@0
    72
sl@0
    73
	CreateTestDirectory(_L("\\F32-TST\\T_CP_PLUGIN\\"));
sl@0
    74
	TestUnicodeVolumeLabel();
sl@0
    75
	TestShortNameBoundary();
sl@0
    76
	TestConsistentShortNameGeneration();
sl@0
    77
	TestConsistentShortNameExtGeneration();
sl@0
    78
	TestDuplicateLongFileNames();
sl@0
    79
	TestDuplicateLongDirNames();
sl@0
    80
	TestLeadingE5Handling();
sl@0
    81
	TestDEF130334();
sl@0
    82
	TestINC127905();
sl@0
    83
	DeleteTestDirectory();
sl@0
    84
	TestCompatibility();
sl@0
    85
	TestINC126563();
sl@0
    86
	
sl@0
    87
	RDebug::Printf("-- T_CP_PLUGIN.CPP DoCodePagePluginTestL");
sl@0
    88
	}
sl@0
    89
sl@0
    90
sl@0
    91
void CallTestsL(void)
sl@0
    92
	{
sl@0
    93
sl@0
    94
	test.Title();
sl@0
    95
	test.Start(_L("Starting T_CP_PLUGIN tests"));
sl@0
    96
sl@0
    97
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
    98
sl@0
    99
	// Test only runs on Fat file systems
sl@0
   100
	TheFs.SessionPath(gSessionPath);
sl@0
   101
	TInt driveNum = CurrentDrive();
sl@0
   102
	TFSName name;
sl@0
   103
	TInt r = TheFs.FileSystemName(name, driveNum);
sl@0
   104
	if (KErrNone == r)
sl@0
   105
		{
sl@0
   106
		if (name.Compare(_L("Fat")) != 0)
sl@0
   107
			{
sl@0
   108
			test.Printf(_L("Test only runs on 'FAT' drives"));
sl@0
   109
			}
sl@0
   110
		else
sl@0
   111
			{
sl@0
   112
			TBuf<16> CodepageDllName(KCP932Name);
sl@0
   113
			r = LoadCodePageDll(CodepageDllName);
sl@0
   114
			test(r == KErrNone || r == KErrAlreadyExists);
sl@0
   115
sl@0
   116
			if(r == KErrNone)
sl@0
   117
				{
sl@0
   118
				// should not allow loading again codepage dll.
sl@0
   119
				r = LoadCodePageDll(CodepageDllName);
sl@0
   120
				test(r == KErrAlreadyExists);
sl@0
   121
sl@0
   122
				}
sl@0
   123
sl@0
   124
			// Enables codepage dll implementation of LocaleUtils functions
sl@0
   125
			TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions);
sl@0
   126
			test(KErrNone == r);
sl@0
   127
sl@0
   128
			DoCodePagePluginTest();
sl@0
   129
sl@0
   130
			// Disables codepage dll implementation of LocaleUtils functions for other base tests
sl@0
   131
			r = TheFs.ControlIo(driveNum, KControlIoDisableFatUtilityFunctions);
sl@0
   132
			test(r == KErrNone);
sl@0
   133
			}
sl@0
   134
		}
sl@0
   135
	else
sl@0
   136
		{
sl@0
   137
		test.Printf(_L("Drive %C: is not ready!"), 'A'+driveNum);
sl@0
   138
		test(EFalse);
sl@0
   139
		}
sl@0
   140
#else
sl@0
   141
	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
sl@0
   142
#endif  // _DEBUG) || _DEBUG_RELEASE
sl@0
   143
	test.End();
sl@0
   144
	}
sl@0
   145