Revisión | 0be998724ab378203f0039ba905f6095782ab769 (tree) |
---|---|
Tiempo | 2012-03-27 00:09:18 |
Autor | qwerty2501 <qwerty2501@user...> |
Commiter | qwerty2501 |
cookie取得処理完全実装
@@ -2,41 +2,64 @@ | ||
2 | 2 | #include "appinfo.h" |
3 | 3 | #include "function.h" |
4 | 4 | #include "bugreport.h" |
5 | - | |
5 | +#include "commanage.h" | |
6 | 6 | |
7 | 7 | #include "namespace_start.h" |
8 | 8 | |
9 | 9 | |
10 | -Bool BugTransfer::Report(BugTransfer &bug){ | |
10 | +Bool BugTransfer::Report()const{ | |
11 | 11 | |
12 | 12 | Bool rslt = false; |
13 | - CWinHttpClient httpClient; | |
13 | + | |
14 | 14 | NString userId; |
15 | 15 | GetnliteUserId(userId); |
16 | 16 | nstringstream bugmessage; |
17 | 17 | |
18 | 18 | bugmessage << _T("version=") << CApplicationInfo::getProductVersion() << _T("&"); |
19 | 19 | bugmessage << _T("nliteUserId=") << userId << _T("&"); |
20 | - bugmessage << _T("summary=") << bug.summary << _T("&"); | |
21 | - bugmessage << _T("function=") << bug.function << _T("&"); | |
22 | - bugmessage << _T("sourcefile=") << bug.sourcefile << _T("&"); | |
23 | - bugmessage << _T("line=") << bug.line << _T("&"); | |
24 | - bugmessage << _T("windowsErrorCode=") << bug.windowsErrorCode << _T("&"); | |
25 | - bugmessage << _T("windowsErrorMessage=") << bug.windowsErrorMessage << _T("&"); | |
20 | + bugmessage << _T("summary=") << summary << _T("&"); | |
21 | + bugmessage << _T("function=") << function << _T("&"); | |
22 | + bugmessage << _T("sourcefile=") << sourcefile << _T("&"); | |
23 | + bugmessage << _T("line=") << line << _T("&"); | |
24 | + bugmessage << _T("windowsErrorCode=") << windowsErrorCode << _T("&"); | |
25 | + bugmessage << _T("windowsErrorMessage=") << windowsErrorMessage << _T("&"); | |
26 | 26 | bugmessage << _T("osVersion=") << GetWindowsVersion(); |
27 | 27 | |
28 | 28 | |
29 | 29 | nregex reg(_T("[\r|\n]")); |
30 | 30 | NString message(std::regex_replace(bugmessage.str(),reg,NString(_T("")))); |
31 | 31 | |
32 | - //MString mmessage; | |
33 | - //ToUTF8(mmessage,message); | |
32 | + CWinHttpClient httpClient; | |
34 | 33 | httpClient->Open(_T("POST"),_T("http://nlite.sourceforge.jp/cgi-bin/bugreport.rb")); |
35 | 34 | httpClient->SetRequestHeader(_T("Content-Type"),_T("application/x-www-form-urlencoded")); |
36 | 35 | httpClient->Send(message.c_str()); |
37 | - std::wcout << message << std::endl; | |
38 | 36 | return rslt; |
39 | 37 | } |
40 | 38 | |
41 | 39 | |
40 | +CBugReporter::CBugReporter(){ | |
41 | + | |
42 | + | |
43 | +} | |
44 | + | |
45 | +CBugReporter::~CBugReporter(){ | |
46 | + | |
47 | + this->m_threadgroup.join_all(); | |
48 | + | |
49 | +} | |
50 | + | |
51 | +Void CBugReporter::Report(const BugTransfer& bug){ | |
52 | + | |
53 | + | |
54 | + | |
55 | + | |
56 | + m_threadgroup.create_thread([ | |
57 | + bug](Void) -> Bool { | |
58 | + CComManage commanage; | |
59 | + return bug.Report(); | |
60 | + }); | |
61 | + | |
62 | + return; | |
63 | +} | |
64 | + | |
42 | 65 | #include "namespace_end.h" |
\ No newline at end of file |
@@ -1,9 +1,13 @@ | ||
1 | 1 | #pragma once |
2 | - | |
2 | +#include <boost\thread.hpp> | |
3 | 3 | #include "define.h" |
4 | 4 | #include "http.h" |
5 | 5 | #include "windowsAPI.h" |
6 | +#include "singleton.h" | |
7 | + | |
8 | + | |
6 | 9 | #include "namespace_start.h" |
10 | + | |
7 | 11 | struct BugTransfer{ |
8 | 12 | NString summary; |
9 | 13 | NString line; |
@@ -15,7 +19,28 @@ struct BugTransfer{ | ||
15 | 19 | |
16 | 20 | |
17 | 21 | public: |
18 | - static Bool Report(BugTransfer &bug); | |
22 | + Bool Report()const; | |
23 | + | |
24 | +}; | |
25 | + | |
26 | + | |
27 | + | |
28 | +class CBugReporter:public SingletonT<CBugReporter>{ | |
29 | + | |
30 | +private: | |
31 | + boost::thread_group m_threadgroup; | |
32 | + | |
33 | + | |
34 | +public: | |
35 | + CBugReporter(); | |
36 | + | |
37 | + ~CBugReporter(); | |
38 | + | |
39 | + | |
40 | + | |
41 | +public: | |
42 | + Void Report(const BugTransfer& bug); | |
43 | + | |
19 | 44 | |
20 | 45 | }; |
21 | 46 |
@@ -0,0 +1,24 @@ | ||
1 | +#pragma once | |
2 | + | |
3 | +#include <Windows.h> | |
4 | +#include "namespace_start.h" | |
5 | + | |
6 | + | |
7 | +class CComManage{ | |
8 | + | |
9 | +public: | |
10 | + | |
11 | + CComManage(){ | |
12 | + ::CoInitialize(nullptr); | |
13 | + } | |
14 | + | |
15 | + ~CComManage(){ | |
16 | + | |
17 | + ::CoUninitialize(); | |
18 | + } | |
19 | + | |
20 | + | |
21 | +}; | |
22 | + | |
23 | + | |
24 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -1,9 +1,11 @@ | ||
1 | 1 | #include "stdafx.h" |
2 | 2 | #include "http.h" |
3 | 3 | |
4 | - | |
4 | +#include "namespace_start.h" | |
5 | 5 | CWinHttpClient::CWinHttpClient(){ |
6 | 6 | |
7 | 7 | this->CreateInstance(WinHttp::CLSID_WinHttpRequest); |
8 | 8 | |
9 | -} | |
\ No newline at end of file | ||
9 | +} | |
10 | + | |
11 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -1,9 +1,12 @@ | ||
1 | 1 | #pragma once |
2 | 2 | #import "winhttp.dll" named_guids |
3 | 3 | |
4 | + | |
5 | +#include "namespace_start.h" | |
4 | 6 | class CWinHttpClient:public WinHttp::IWinHttpRequestPtr{ |
5 | 7 | |
6 | 8 | public: |
7 | 9 | CWinHttpClient(); |
8 | 10 | |
9 | -}; | |
\ No newline at end of file | ||
11 | +}; | |
12 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -73,7 +73,9 @@ Bool Exception:: Report(){ | ||
73 | 73 | bug.line = boost::lexical_cast<NString>(getLineNo()); |
74 | 74 | bug.windowsErrorCode = boost::lexical_cast<NString>(osErrorCode); |
75 | 75 | GetWindowsErrorMessage(bug.windowsErrorMessage,osErrorCode); |
76 | - BugTransfer::Report(bug); | |
76 | + | |
77 | + auto &reporter = CBugReporter::GetInstance(); | |
78 | + reporter.Report(bug); | |
77 | 79 | |
78 | 80 | |
79 | 81 | return false; |
@@ -104,6 +104,7 @@ | ||
104 | 104 | <ItemGroup> |
105 | 105 | <ClInclude Include="appinfo.h" /> |
106 | 106 | <ClInclude Include="bugreport.h" /> |
107 | + <ClInclude Include="commanage.h" /> | |
107 | 108 | <ClInclude Include="define.h" /> |
108 | 109 | <ClInclude Include="function.h" /> |
109 | 110 | <ClInclude Include="http.h" /> |
@@ -111,6 +112,7 @@ | ||
111 | 112 | <ClInclude Include="namespace_start.h" /> |
112 | 113 | <ClInclude Include="nexception.h" /> |
113 | 114 | <ClInclude Include="raii.h" /> |
115 | + <ClInclude Include="singleton.h" /> | |
114 | 116 | <ClInclude Include="stdafx.h" /> |
115 | 117 | <ClInclude Include="targetver.h" /> |
116 | 118 | <ClInclude Include="unit_test.h" /> |
@@ -60,6 +60,12 @@ | ||
60 | 60 | <ClInclude Include="raii.h"> |
61 | 61 | <Filter>ヘッダー ファイル</Filter> |
62 | 62 | </ClInclude> |
63 | + <ClInclude Include="singleton.h"> | |
64 | + <Filter>ヘッダー ファイル</Filter> | |
65 | + </ClInclude> | |
66 | + <ClInclude Include="commanage.h"> | |
67 | + <Filter>ヘッダー ファイル</Filter> | |
68 | + </ClInclude> | |
63 | 69 | </ItemGroup> |
64 | 70 | <ItemGroup> |
65 | 71 | <ClCompile Include="stdafx.cpp"> |
@@ -0,0 +1,21 @@ | ||
1 | +#pragma once | |
2 | + | |
3 | + | |
4 | +#include "namespace_start.h" | |
5 | +template<typename T> | |
6 | +class SingletonT{ | |
7 | + | |
8 | +protected: | |
9 | + SingletonT(){} | |
10 | + | |
11 | +public: | |
12 | + static T &GetInstance(){ | |
13 | + | |
14 | + static T target; | |
15 | + | |
16 | + | |
17 | + return target; | |
18 | + } | |
19 | + | |
20 | +}; | |
21 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -22,6 +22,7 @@ | ||
22 | 22 | #include <strsafe.h> |
23 | 23 | #include <regex> |
24 | 24 | #include <array> |
25 | +#include <boost\thread.hpp> | |
25 | 26 | #include <boost\test\unit_test.hpp> |
26 | 27 | #include <boost\lexical_cast.hpp> |
27 | 28 | #include <boost\utility.hpp> |
@@ -14,15 +14,6 @@ Void UnitTest(){ | ||
14 | 14 | std::wcout << GetWindowsVersion() << std::endl; |
15 | 15 | |
16 | 16 | |
17 | - try{ | |
18 | - | |
19 | - throw Exception(_T("testerror"),__LINE__,_T(__FILE__),_T(__FUNCTION__)); | |
20 | - | |
21 | - } catch(Exception &e){ | |
22 | - e.Report(); | |
23 | - | |
24 | - | |
25 | - } | |
26 | 17 | |
27 | 18 | /* |
28 | 19 | BOOST_CHECK(GetWindowsVersion().length() > 0); |
@@ -45,7 +36,20 @@ Void UnitTest(){ | ||
45 | 36 | BOOST_CHECK(FAILED(result.m_hResult)); |
46 | 37 | |
47 | 38 | */ |
48 | - | |
39 | + | |
40 | + /* | |
41 | + for(int i = 0;i < 10;i++){ | |
42 | + try{ | |
43 | + | |
44 | + throw Exception(_T("testerror"),__LINE__,_T(__FILE__),_T(__FUNCTION__)); | |
45 | + | |
46 | + } catch(Exception &e){ | |
47 | + e.Report(); | |
48 | + | |
49 | + | |
50 | + } | |
51 | + } | |
52 | + */ | |
49 | 53 | } |
50 | 54 | |
51 | 55 |
@@ -1,6 +1,8 @@ | ||
1 | 1 | #include "stdafx.h" |
2 | +#include <nlite_common\bugreport.h> | |
2 | 3 | #include "cookieGetResult.h" |
3 | - | |
4 | +#include "cookiemaster.h" | |
5 | +#include <nlite_common\windowsAPI.h> | |
4 | 6 | |
5 | 7 | #include "namespace_start.h" |
6 | 8 |
@@ -11,6 +13,62 @@ CCookieGetResult::CCookieGetResult(browsertype::BrowserType bt): | ||
11 | 13 | |
12 | 14 | {} |
13 | 15 | |
16 | +Void CCookieGetResult::Report(){ | |
17 | + | |
18 | + BugTransfer bug; | |
19 | + | |
20 | + bug.function = _T("cookieGetFunction"); | |
21 | + bug.line = _T("0"); | |
22 | + bug.sourcefile = _T("cookieGetFile"); | |
23 | + nstringstream ns; | |
24 | + NString btstr = CCookieMaster::BrowserTypeToString(this->browserType); | |
25 | + NString rcstr = CCookieMaster::ResultCodeToString(this->resultCode); | |
26 | + ns << _T("BT:") << btstr << _T(",RC:") << rcstr << _T(","); | |
27 | + bug.windowsErrorCode = _T(""); | |
28 | + bug.windowsErrorMessage =_T(""); | |
29 | + switch(this->resultCode){ | |
30 | + | |
31 | + | |
32 | + case resultcode::ERR_SQLITE: | |
33 | + | |
34 | + ns << _T("sqliteerr:") << this->GetExtendCode().sqliteResult; | |
35 | + | |
36 | + break; | |
37 | + | |
38 | + case resultcode::ERR_IEAPI: | |
39 | + | |
40 | + ns << _T("IEnomalerr:"); | |
41 | + goto winerr; | |
42 | + | |
43 | + case resultcode::ERR_IEAPI_SEC: | |
44 | + | |
45 | + ns << _T("IESecerr:"); | |
46 | + goto winerr; | |
47 | + | |
48 | +winerr: | |
49 | + { | |
50 | + NString winerrStr; | |
51 | + | |
52 | + bug.windowsErrorCode = boost::lexical_cast<NString>(this->GetExtendCode().hResult); | |
53 | + GetWindowsErrorMessage(winerrStr,this->GetExtendCode().hResult); | |
54 | + bug.windowsErrorMessage = winerrStr; | |
55 | + } | |
56 | + break; | |
57 | + | |
58 | + case resultcode::OK: | |
59 | + case resultcode::UNDEFINED: | |
60 | + | |
61 | + break; | |
62 | + | |
63 | + | |
64 | + } | |
65 | + bug.summary = ns.str(); | |
66 | + | |
67 | + auto &reporter = CBugReporter::GetInstance(); | |
68 | + reporter.Report(bug); | |
69 | + | |
70 | + | |
71 | +} | |
14 | 72 | |
15 | 73 | |
16 | 74 | Void CCookieGetResult::SetFindFlag(Bool findFlag){ |
@@ -52,6 +52,12 @@ public: | ||
52 | 52 | /// |
53 | 53 | CCookieGetResult(browsertype::BrowserType bt); |
54 | 54 | |
55 | + | |
56 | + /// | |
57 | + ///報告関数 | |
58 | + /// | |
59 | + Void Report(); | |
60 | + | |
55 | 61 | }; |
56 | 62 | |
57 | 63 | static_assert(sizeof(CCookieGetResult) <= 8,"CCookieGetResult size error"); |
@@ -25,6 +25,14 @@ public: | ||
25 | 25 | return resultList; |
26 | 26 | } |
27 | 27 | |
28 | + ~CCookieGetterT(){ | |
29 | + | |
30 | + for each(CCookieGetResult rslt in resultList){ | |
31 | + | |
32 | + rslt.Report(); | |
33 | + } | |
34 | + | |
35 | + } | |
28 | 36 | |
29 | 37 | Bool GetCookie(const NString &domein,const NString &name,CCookie &cookie){ |
30 | 38 |
@@ -46,14 +54,9 @@ protected: | ||
46 | 54 | return false; |
47 | 55 | |
48 | 56 | } |
49 | - /* | |
50 | - CCookieGetResult ForceSearch(const Byte* data,UInt dataSize,const NString &domein,const NString &name,CCookie &cookie){ | |
51 | 57 | |
52 | - throw Exception(_T("ForceSearchが実装されていません"),__LINE__,_T(__FILE__),_T(__FUNCTION__)); | |
58 | + | |
53 | 59 | |
54 | - return CCookieGetResult(browsertype::UNDEFINED); | |
55 | - } | |
56 | - */ | |
57 | 60 | |
58 | 61 | }; |
59 | 62 |
@@ -0,0 +1,114 @@ | ||
1 | +#include "stdafx.h" | |
2 | +#include <nlite_common\nexception.h> | |
3 | +#include "iecookiegetter.h" | |
4 | +#include "firefoxcookiegetter.h" | |
5 | +#include "iecomponentcookiegetter.h" | |
6 | +#include "chromecookiegetter.h" | |
7 | +#include "safaricookiegetter.h" | |
8 | +#include "operacookiegetter.h" | |
9 | +#include "cookiemaster.h" | |
10 | + | |
11 | + | |
12 | + | |
13 | +#include "namespace_start.h" | |
14 | + | |
15 | + | |
16 | + | |
17 | +Bool CCookieMaster::GetCookie(browsertype::BrowserType bt,const NString &domein,const NString &name,CCookie &cookie){ | |
18 | + | |
19 | + Bool result = false; | |
20 | + switch(bt){ | |
21 | + | |
22 | + case browsertype::IE: | |
23 | + { | |
24 | + CIECookieGetter iecookie; | |
25 | + result = iecookie.GetCookie(domein,name,cookie); | |
26 | + | |
27 | + } | |
28 | + break; | |
29 | + case browsertype::FIREFOX: | |
30 | + { | |
31 | + CFireFoxCookieGetter firefoxcookie; | |
32 | + result = firefoxcookie.GetCookie(domein,name,cookie); | |
33 | + | |
34 | + } | |
35 | + break; | |
36 | + case browsertype::CHROME: | |
37 | + { | |
38 | + CChromeCookieGetter chromecookie; | |
39 | + result = chromecookie.GetCookie(domein,name,cookie); | |
40 | + | |
41 | + } | |
42 | + break; | |
43 | + case browsertype::SAFARI: | |
44 | + { | |
45 | + CSafariCookieGetter safaricookie; | |
46 | + result = safaricookie.GetCookie(domein,name,cookie); | |
47 | + | |
48 | + } | |
49 | + break; | |
50 | + | |
51 | + case browsertype::OPERA: | |
52 | + { | |
53 | + COperaCookieGetter operacookie; | |
54 | + result = operacookie.GetCookie(domein,name,cookie); | |
55 | + | |
56 | + } | |
57 | + break; | |
58 | + case browsertype::IECOMPONENT: | |
59 | + { | |
60 | + CIEComponentGetter iecomcookie; | |
61 | + result = iecomcookie.GetCookie(domein,name,cookie); | |
62 | + } | |
63 | + break; | |
64 | + case browsertype::UNDEFINED: | |
65 | + { | |
66 | + | |
67 | + THROW_EXCEPTION(Exception,_T("クッキー取得に指定されたブラウザの種類が未定義です")); | |
68 | + | |
69 | + } | |
70 | + break; | |
71 | + default: | |
72 | + { | |
73 | + THROW_EXCEPTION(Exception,_T("クッキー取得に指定されたブラウザの種類が不明な値です")); | |
74 | + | |
75 | + | |
76 | + } | |
77 | + break; | |
78 | + } | |
79 | + | |
80 | + return result; | |
81 | +} | |
82 | + | |
83 | + | |
84 | +const NChar *CCookieMaster::BrowserTypeToString(browsertype::BrowserType bt){ | |
85 | + | |
86 | + switch(bt){ | |
87 | + case browsertype::IE: return _T("IE"); | |
88 | + case browsertype::FIREFOX:return _T("FireFox"); | |
89 | + case browsertype::CHROME:return _T("Chrome"); | |
90 | + case browsertype::SAFARI:return _T("Safari"); | |
91 | + case browsertype::OPERA:return _T("Opera"); | |
92 | + case browsertype::IECOMPONENT:return _T("IEComponent"); | |
93 | + case browsertype::UNDEFINED:return _T("UnDefined"); | |
94 | + | |
95 | + default:return _T("UnKnown"); | |
96 | + | |
97 | + } | |
98 | + | |
99 | +} | |
100 | + | |
101 | +const NChar *CCookieMaster::ResultCodeToString(resultcode::ResultCode rc){ | |
102 | + switch(rc){ | |
103 | + case resultcode::OK:return _T("OK"); | |
104 | + case resultcode::ERR_SQLITE:return _T("Err_Sqlite"); | |
105 | + case resultcode::ERR_IEAPI:return _T("Err_IE"); | |
106 | + case resultcode::ERR_IEAPI_SEC:return _T("Err_IESec"); | |
107 | + case resultcode::UNDEFINED :return _T("Undefined"); | |
108 | + | |
109 | + default:return _T("UnKnown"); | |
110 | + } | |
111 | +} | |
112 | + | |
113 | + | |
114 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -0,0 +1,27 @@ | ||
1 | +#pragma once | |
2 | + | |
3 | +#include <nlite_common\singleton.h> | |
4 | +#include "define.h" | |
5 | +#include "cookie.h" | |
6 | + | |
7 | +#include "namespace_start.h" | |
8 | + | |
9 | + | |
10 | + | |
11 | +class CCookieMaster:public SingletonT<CCookieMaster>{ | |
12 | + | |
13 | + | |
14 | +public: | |
15 | + Bool GetCookie(browsertype::BrowserType bt,const NString &domein,const NString &name,CCookie &cookie); | |
16 | + | |
17 | + | |
18 | + static const NChar *BrowserTypeToString(browsertype::BrowserType bt); | |
19 | + | |
20 | + static const NChar *ResultCodeToString(resultcode::ResultCode rc); | |
21 | + | |
22 | +}; | |
23 | + | |
24 | + | |
25 | + | |
26 | + | |
27 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -55,6 +55,7 @@ protected: | ||
55 | 55 | val = std::regex_replace(val,reg,NString(_T(""))); |
56 | 56 | cookie.SetCookieValue(val); |
57 | 57 | result.SetFindFlag(true); |
58 | + result.SetResultCode(resultcode::OK); | |
58 | 59 | } else { |
59 | 60 | |
60 | 61 |
@@ -9,7 +9,7 @@ Bool CIEComponentGetter::GetCookieInternal(const NString &domein,const NString & | ||
9 | 9 | |
10 | 10 | CCookieGetResult result = this->GetCookieIEAPI(domein,name,cookie,false); |
11 | 11 | |
12 | - if(result.GetResultCode() != resultcode::OK){ | |
12 | + if(result.GetResultCode() != resultcode::OK || (!result.IsFound())){ | |
13 | 13 | |
14 | 14 | resultList.push_back(result); |
15 | 15 | CCookieGetResult forceresult = CIEComponentGetter::ForceSearchFiles(this->normalDirectry,domein,name,cookie,CIEComponentGetter::Fancta); |
@@ -16,7 +16,7 @@ Bool CIECookieGetter::GetCookieInternal(const NString &domein,const NString &nam | ||
16 | 16 | Bool secFlag = IEIsSecurityMode(); |
17 | 17 | CCookieGetResult result = this->GetCookieIEAPI(domein,name,cookie,secFlag); |
18 | 18 | |
19 | - if(result.GetResultCode() != resultcode::OK){ | |
19 | + if(result.GetResultCode() != resultcode::OK || (!result.IsFound())){ | |
20 | 20 | |
21 | 21 | resultList.push_back(result); |
22 | 22 | CCookieGetResult forceresult = CIECookieGetter::ForceSearchFiles(secFlag ? this->securityCookiedir : this->normalDirectry,domein,name,cookie,CIECookieGetter::Fancta); |
@@ -103,6 +103,7 @@ | ||
103 | 103 | </ItemGroup> |
104 | 104 | <ItemGroup> |
105 | 105 | <ClInclude Include="chromecookiegetter.h" /> |
106 | + <ClInclude Include="cookiemaster.h" /> | |
106 | 107 | <ClInclude Include="iecomponentcookiegetter.h" /> |
107 | 108 | <ClInclude Include="cookie.h" /> |
108 | 109 | <ClInclude Include="cookieGetResult.h" /> |
@@ -126,6 +127,7 @@ | ||
126 | 127 | <ClCompile Include="chromecookiegetter.cpp" /> |
127 | 128 | <ClCompile Include="cookie.cpp" /> |
128 | 129 | <ClCompile Include="cookieGetResult.cpp" /> |
130 | + <ClCompile Include="cookiemaster.cpp" /> | |
129 | 131 | <ClCompile Include="firefoxcookiegetter.cpp" /> |
130 | 132 | <ClCompile Include="iecomponentcookiegetter.cpp" /> |
131 | 133 | <ClCompile Include="iecookiegetter.cpp" /> |
@@ -75,6 +75,9 @@ | ||
75 | 75 | <ClInclude Include="safaricookiegetter.h"> |
76 | 76 | <Filter>ヘッダー ファイル</Filter> |
77 | 77 | </ClInclude> |
78 | + <ClInclude Include="cookiemaster.h"> | |
79 | + <Filter>ヘッダー ファイル</Filter> | |
80 | + </ClInclude> | |
78 | 81 | </ItemGroup> |
79 | 82 | <ItemGroup> |
80 | 83 | <ClCompile Include="stdafx.cpp"> |
@@ -107,5 +110,8 @@ | ||
107 | 110 | <ClCompile Include="safaricookiegetter.cpp"> |
108 | 111 | <Filter>ソース ファイル</Filter> |
109 | 112 | </ClCompile> |
113 | + <ClCompile Include="cookiemaster.cpp"> | |
114 | + <Filter>ソース ファイル</Filter> | |
115 | + </ClCompile> | |
110 | 116 | </ItemGroup> |
111 | 117 | </Project> |
\ No newline at end of file |
@@ -18,4 +18,5 @@ | ||
18 | 18 | #include <boost\test\unit_test.hpp> |
19 | 19 | #include <boost/format.hpp> |
20 | 20 | #include <boost\lexical_cast.hpp> |
21 | +#include <boost\thread.hpp> | |
21 | 22 | #include <atlfile.h> |
@@ -10,6 +10,7 @@ | ||
10 | 10 | #include "operacookiegetter.h" |
11 | 11 | #include "iecookiegetter.h" |
12 | 12 | #include "cookieGetter.h" |
13 | +#include "cookiemaster.h" | |
13 | 14 | #include "unit_test.h" |
14 | 15 | |
15 | 16 |
@@ -22,6 +23,27 @@ | ||
22 | 23 | |
23 | 24 | class TestGetter:public CCookieGetterT<TestGetter>{}; |
24 | 25 | |
26 | + | |
27 | +static Void CookieManageTest(browsertype::BrowserType bt){ | |
28 | + | |
29 | + CCookie cookie; | |
30 | + NString domein = _T("nicovideo.jp"); | |
31 | + NString name = _T("user_session"); | |
32 | + MString cookieval; | |
33 | + NString browsertypestr = CCookieMaster::BrowserTypeToString(bt); | |
34 | + MString browsertypestrm; | |
35 | + ToSJIS(browsertypestrm,browsertypestr); | |
36 | + auto &cookiemaster = CCookieMaster::GetInstance(); | |
37 | + Bool result = false; | |
38 | + result = cookiemaster.GetCookie(bt,domein,name,cookie); | |
39 | + ToSJIS(cookieval,cookie.GetCookieValue()); | |
40 | + | |
41 | + std::cout <<"browsertype:" << browsertypestrm << "result:" << result << "cookie:" << cookieval << std::endl; | |
42 | + | |
43 | + BOOST_CHECK_MESSAGE(result,"cookieが取れませんでした"); | |
44 | + | |
45 | +} | |
46 | + | |
25 | 47 | Void UnitTest(){ |
26 | 48 | |
27 | 49 | CCookieGetResult cookieResult(browsertype::UNDEFINED); |
@@ -269,6 +291,13 @@ Void UnitTest(){ | ||
269 | 291 | } |
270 | 292 | |
271 | 293 | } |
294 | + | |
295 | + CookieManageTest(browsertype::IE); | |
296 | + CookieManageTest(browsertype::FIREFOX); | |
297 | + CookieManageTest(browsertype::CHROME); | |
298 | + CookieManageTest(browsertype::IECOMPONENT); | |
299 | + CookieManageTest(browsertype::OPERA); | |
300 | + CookieManageTest(browsertype::SAFARI); | |
272 | 301 | return; |
273 | 302 | |
274 | 303 | } |
@@ -9,7 +9,7 @@ | ||
9 | 9 | |
10 | 10 | #define BOOST_TEST_MODULE SimpleTest |
11 | 11 | |
12 | -//#include "commontest.h" | |
12 | +#include "commontest.h" | |
13 | 13 | #include "cookietest.h" |
14 | 14 | |
15 | 15 |