• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Codec_UT_RTComponent.cpp
2 #include <windows.h>
3 #include <iostream>
4 #include "Codec_UT_RTComponent.h"
5 
6 using namespace Codec_UT_RTComponent;
7 using namespace Platform;
8 using namespace Windows;
9 using namespace Windows::Storage;
10 
11 typedef int (*pfTestAllCases) (int argc, char** argv);
12 
CodecUTTest()13 CodecUTTest::CodecUTTest() {
14 }
15 
TestAllCases()16 int CodecUTTest::TestAllCases() {
17   int   argc = 2;
18   int   iRet = 0;
19   char* argv[6];
20 
21   HMODULE         phTestCasesDllHandler = NULL;
22   pfTestAllCases  pUTHandler            = NULL;
23   LPCWSTR         cTestCasesDllDLLName  = L"ut.dll";
24 
25   // output xml file location
26   char OutputPath[256] = { 0 };
27   Windows::Storage::StorageFolder^ OutputLocation;
28   Platform::String^ OutputLocationPath;
29 
30   OutputLocation = ApplicationData::Current->LocalFolder;
31   OutputLocationPath = Platform::String::Concat (OutputLocation->Path, "\\Shared\\");
32   const wchar_t* pWcharOutputFile = OutputLocationPath->Data();
33 
34   int size = wcslen (pWcharOutputFile);
35   OutputPath[size] = 0;
36   for (int y = 0; y < size; y++) {
37     OutputPath[y] = (char)pWcharOutputFile[y];
38   }
39 
40   // load dynamic library
41   phTestCasesDllHandler = LoadPackagedLibrary (cTestCasesDllDLLName, 0);
42   DWORD dw = GetLastError();
43   if (NULL == phTestCasesDllHandler) {
44     std::cout << "failed to load dll,error code is : " << dw << std::endl;
45     return 1;
46   }
47 
48   pUTHandler = (pfTestAllCases)GetProcAddress (phTestCasesDllHandler, "CodecUtMain");
49 
50   if (NULL == pUTHandler) {
51     std::cout << "failed to load function" << std::endl;
52     return 2;
53   }
54 
55   // test all cases
56   argv[0] = "CodecUTAPP";
57   argv[1] = OutputPath;
58   argc    = 2;
59 
60   iRet = pUTHandler(argc, argv);
61 
62   return iRet;
63 }
64