Cookie test item in qual-e.appspot.com would fail at gold version(rc_11) - cobalt

When test with https://qual-e.appspot.com, the cookie item would fail at gold version(rc_11), but it would pass with qa version, from the souce code ,
it seemed the gold version will not support cookie feature, and if I keep the code of gold the same with qa version, then it will pass the cookie test, so how to fix this failed item?
void Document::set_cookie(const std::string& cookie) {
#if defined(COBALT_BUILD_TYPE_GOLD)
UNREFERENCED_PARAMETER(cookie);
#else
if (cookie_jar_) {
cookie_jar_->SetCookie(url_as_gurl(), cookie);
}
#endif
}
std::string Document::cookie() const {
#if defined(COBALT_BUILD_TYPE_GOLD)
return std::string();
#else
if (cookie_jar_) {
return cookie_jar_->GetCookies(url_as_gurl());
} else {
DLOG(WARNING) << "Document has no cookie jar";
return "";
}
#endif
}

we're going to change the Qual-E test case soon. Thanks for your patience.

Related

How to handle saving and loading different versions of a file?

In making an application that saves files with a specific format which in the future will have added or different functionality, requiring the saved file to have a different format, are there any techniques available to handle this "versioning"?
I would be interested in reading into some of them explaining how it is possible to load all the possible formats of the saved file that were created by the different versions of the application.
My idea currently is to save a version indicator in the saved file and use distinct load functions for every "version" that had it's own format, trying to tie them all with the current functionality of the latest version of the app.
This is mostly opinion based so handle it as such... Here are my insights on the topic:
fileformat
You should have 2 identificators. One for file format sometimes called magic number and second version. Both should be somewhere at the start of file and usually encoded as ASCII so you can easily check them with notepad or whatever.
Its a good idea to have chunks of data with they own type and version identificators.
loader - single fileformat detector
I use this to check for specific fileformat. The input is array (small usually 1Kbyte) holding first bytes of file, array size and file size. The function checks if the file is valid file of some type. This is used to autodetect fileformat and not relay on file extension (necessity on Windows and low grade users as they often corrupt the file extention)
The function returns true/false after checking identificators (and or file logic)
loader - single fileformat
This should load file into your app. For multi versions you got 2 options. Either have separate code for each version or one function partitioned with if statements like this:
if (version==???) ...
if (version>=???) ... else ...
if ((version>=???)&&(version<???)) ...
to manage the diferent parts.
I prefer the partitioned code approach as its usually less code and better manageable because different versions usually adds just some minor changes and most of the code states the same.
loader - multi fileformat
Simply load first bytes of file into memory and check all the supported fileformats using function from #2. Once succesfully detected fileformat load the file using its loader function from #3. If no fileformat detected then use file extention ...
Here simple C++/VCL example of #4 from my SVG loader class:
bool decode_interface_class::load(AnsiString name)
{
int hnd=-1;
int siz=0,siz0=0;
BYTE *dat=NULL;
reset();
#ifdef decode_interface_log
decode_id.num=0;
decode_log="";
#endif
decode_cfg =true;
decode_col =true;
decode_tool=true;
decode_ext=ExtractFileExt(name).LowerCase();
decoded_ext=".";
decoded_info="";
decode_emf emf;
decode_wmf wmf;
decode_dkr dkr;
decode_dk3 dk3;
decode_box box;
decode_bxl bxl;
decode_dxf dxf;
decode_svg svg;
decode_v2x v2x;
decode_v2d v2d;
const int _size=4096;
BYTE head[_size];
#ifdef decode_interface_log
siz=0; // find minimal size
if (siz<_decode_emf_hdr) siz=_decode_emf_hdr;
if (siz<_decode_wmf_hdr) siz=_decode_wmf_hdr;
if (siz<_decode_dkr_hdr) siz=_decode_dkr_hdr;
if (siz<_decode_dk3_hdr) siz=_decode_dk3_hdr;
if (siz<_decode_box_hdr) siz=_decode_box_hdr;
if (siz<_decode_bxl_hdr) siz=_decode_bxl_hdr;
if (siz<_decode_dxf_hdr) siz=_decode_dxf_hdr;
if (siz<_decode_svg_hdr) siz=_decode_svg_hdr;
if (siz<_decode_v2x_hdr) siz=_decode_v2x_hdr;
if (siz<_decode_v2d_hdr) siz=_decode_v2d_hdr;
if (siz>_size)
{
decode_log+="Decoding header size too small needed to be "+AnsiString(siz)+" Bytes.\r\n";
}
#endif
hnd=FileOpen(name,fmOpenRead);
if (hnd<0)
{
#ifdef decode_interface_log
decode_log+="File "+name+" not found.\r\n";
#endif
return false;
}
siz=FileSeek(hnd,0,2);
FileSeek(hnd,0,0);
dat=new BYTE[siz];
if (dat==NULL)
{
#ifdef decode_interface_log
decode_log+="Not enough memory need: "+AnsiString(siz)+" Bytes.\r\n";
#endif
FileClose(hnd);
return false;
}
siz0=siz;
siz=FileRead(hnd,dat,siz);
FileClose(hnd);
if (siz!=siz0)
{
#ifdef decode_interface_log
decode_log+="Disc drive or file system error.\r\n";
#endif
}
this[0].filename=name;
// file signature detection
for (int i=0;i<_size;i++) if (i<siz) head[i]=dat[i]; else head[i]=0;
if (emf.is_header(head,_size,siz)) { decoded_ext=_decode_emf_ext; emf.load(this[0],dat,siz); }
else if (wmf.is_header(head,_size,siz)) { decoded_ext=_decode_wmf_ext; wmf.load(this[0],dat,siz); }
else if (dkr.is_header(head,_size,siz)) { decoded_ext=_decode_dkr_ext; dkr.load(this[0],dat,siz); }
else if (dk3.is_header(head,_size,siz)) { decoded_ext=_decode_dk3_ext; dk3.load(this[0],dat,siz); }
else if (box.is_header(head,_size,siz)) { decoded_ext=_decode_box_ext; box.load(this[0],dat,siz); }
else if (bxl.is_header(head,_size,siz)) { decoded_ext=_decode_bxl_ext; bxl.load(this[0],dat,siz); }
else if (dxf.is_header(head,_size,siz)) { decoded_ext=_decode_dxf_ext; dxf.load(this[0],dat,siz); }
else if (svg.is_header(head,_size,siz)) { decoded_ext=_decode_svg_ext; svg.load(this[0],dat,siz); }
else if (v2x.is_header(head,_size,siz)) { decoded_ext=_decode_v2x_ext; v2x.load(this[0],dat,siz); }
else if (v2d.is_header(head,_size,siz)) { decoded_ext=_decode_v2d_ext; v2d.load(this[0],dat,siz); }
// if fail use file extension
else if (decode_ext==_decode_emf_ext) { decoded_ext=_decode_emf_ext; emf.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_wmf_ext) { decoded_ext=_decode_wmf_ext; wmf.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_dkr_ext) { decoded_ext=_decode_dkr_ext; dkr.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_dk3_ext) { decoded_ext=_decode_dk3_ext; dk3.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_box_ext) { decoded_ext=_decode_box_ext; box.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_bxl_ext) { decoded_ext=_decode_bxl_ext; bxl.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_dxf_ext) { decoded_ext=_decode_dxf_ext; dxf.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_svg_ext) { decoded_ext=_decode_svg_ext; svg.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_v2x_ext) { decoded_ext=_decode_v2x_ext; v2x.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
else if (decode_ext==_decode_v2d_ext) { decoded_ext=_decode_v2d_ext; v2d.load(this[0],dat,siz); decoded_info="*"+decoded_info; }
// if fail then error
else{
#ifdef decode_interface_log
decode_log+="File "+name+" not recognized.\r\n";
#endif
}
if (decode_cfg)
{
if (!decode_col )
{
if (decode_tool) set_cfgs (dk3_charaktool ,33);
set_colors(dk3_charakcolor,33);
}
if (!decode_tool) set_tools (dk3_charaktool ,33);
}
#ifdef decode_interface_log
if (decode_ext!=decoded_ext)
decode_log+="Wrong file extension in "+name+" should be \""+decoded_ext+"\"\r\n";
hnd=FileCreate(ExtractFilePath(Application->ExeName)+"svg_decode.log");
FileWrite(hnd,decode_log.c_str(),decode_log.Length());
FileClose(hnd);
#endif
compute();
compute_objsize();
if (dat) delete[] dat;
return true;
}
Each fileformat has defined its header size _decode_???_hdr in bytes and default file extention _decode_??_ext for the detection of fileformat. Functions ???.is_header(...) are the #2 and ???.load(...) are the #3. I am using loading from memory instead of direct file access because its better suite my needs. However this is not convenient for too big files.

Windows Bitmap print driver winddk OEMNextBand, OEMSendPage

I am observing the OEMSendPage doesn't get invoked always.
When does OEMSendPage get called?
We have a legacy printer which does some processing inside OEMSendPage. I hate to move it to a different place in the process. It has been working but now I am working on some enhancements and need to figure this out.
The other commands are OEMStartPage, OEMStartDoc, OEMTextOut, OEMStartBanding,OEMNextBand,OEMEndDoc.
These all are called except SendPage.
Currently I am attaching VS to spool.exe and the printer is installed at File:port.
When does SendPage command get called?
static const DRVFN s_aOemHookFuncs[] =
#if defined(IMPL_TEXTOUT)
{INDEX_DrvTextOut, (PFN)OEMTextOut},
#endif
#if defined(IMPL_TRANSPARENTBLT)
{INDEX_DrvTransparentBlt, (PFN)OEMTransparentBlt},
#endif
#if defined(IMPL_STARTDOC)
{INDEX_DrvStartDoc, (PFN)OEMStartDoc},
#endif
#if defined(IMPL_ENDDOC)
{INDEX_DrvEndDoc, (PFN)OEMEndDoc},
#endif
#if defined(IMPL_STARTPAGE)
{INDEX_DrvStartPage, (PFN)OEMStartPage},
#endif
#if defined(IMPL_SENDPAGE)
{INDEX_DrvSendPage, (PFN)OEMSendPage},
#endif
As an update I found on the following link
https://learn.microsoft.com/en-us/windows-hardware/drivers/print/rendering-a-print-job#-banding-not-in-use
So I added the part of processing to NextBand also including SendPage.
But something is not correct. OEMNextBand gets called multiple times and the PCL has many pages. The original is only one page but PCL has so many pages.
Can anyone suggest?
char gszPageText[32767];
BOOL APIENTRY
OEMStartBanding(
SURFOBJ *pso,
POINTL *pptl
)
{
return (pOemPDEV->m_pfnDrvStartBanding)(pso,
pptl);
}
BOOL APIENTRY
OEMNextBand(
SURFOBJ *pso,
POINTL *pptl
)
/*++
{
//VERBOSE(L"OEMNextBand entry.");
PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev;
POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM;
// Punt call back to UNIDRV.
BOOL b= (pOemPDEV->m_pfnDrvNextBand)(pso,
pptl);
if (pptl != NULL && pptl->x == -1 && pptl->y == -1)
{
BOOL c = DOPCLProcessingPerPage(pso, gFirstPage, gszPageText);
if (!c)
return TRUE;
}
//if (!CreatePCLRasterGraphicPage(pso, gFirstPage, gszPageText))
//return TRUE;
return b;
}
DrvEnableSurface to call EngModifySurface to disable banding. I don't know the pros and cons of disabling banding w.r.t performance. This is a bitmap driver
Edited
**For Mono**
StartDoc
-- then for as many pages in the document
StartPage
SendPage
EndDoc
**For Colour**
StartDoc
-- then for as many pages in the document
StartPage
StartBanding
-- then for so many bands
NextBand
SendPage ?? (what is the send page equivalent here for color)
EndDoc
**
Edited for EnableDriverSurface
static const DRVFN s_aOemHookFuncs[] =
{
{INDEX_DrvEndDoc, (PFN)OEMEndDoc},
{INDEX_DrvSendPage, (PFN)OEMSendPage},
{INDEX_DrvStartBanding, (PFN)OEMStartBanding},
{INDEX_DrvNextBand, (PFN)OEMNextBand},
{INDEX_DrvTextOut, (PFN)OEMTextOut},
{INDEX_DrvStartPage, (PFN)OEMStartPage},
{INDEX_DrvStartDoc,(PFN)OEMStartDoc},
//added this
{INDEX_DrvEnableSurface ,(PFN)DrvEnableSurface}
// {INDEX_DrvEnableSurface, (PFN)DrvEnableSurface},
};
HSURF APIENTRY DrvEnableSurface(
DHPDEV dhpdev)
{
HSURF hsurf;
SIZEL sizl;
ULONG ulBitmapType;
FLONG flHooks;
// Create engine bitmap around frame buffer.
PDEVOBJ ppdev = (PDEVOBJ)dhpdev;
POEMPDEV pOemPDEV = (POEMPDEV)ppdev->pdevOEM;
EngModifySurface(hsurf,......)
return(hsurf);
}
**

E1740 lambda captured variable of type "..." cannot be copied to closure class field of type "..."

I have recently installed VS 2019 and opened up my project I created in VS 2017. The software works fine but there is a bug in VS with lambda captured variables. MS apparently is aware of said issue, but I was wondering if anyone else had come across this recently and if you have, have you managed to solve it?
Example bit of code from my project, the intellisense has flagged up every line where "[this]" appears. The error / bug reads
lambda captured variable of type "MainPage^*" cannot be copied to closure class field of type "MainPage^"
if (_serialPort1 != nullptr)
{
concurrency::create_task(WriteToSerialDeviceAsync(cancellationTokenSource_serialPort1->get_token(),
Arduino_Device.Outgoing_Bytes, PORT_1)).then([this](concurrency::task<void> previousTask) {
try
{
previousTask.get();
}
catch (Platform::COMException^ ex)
{
this->DataStreamWindow->Text += "\r\n!EXCEPTION CAUGHT! " + ex->Message;
}
});
}
Ok, I managed to stumble upon a somewhat ugly hack to fix this.
Rather than pass [this] into the lambda, I added the line auto _this = this; prior to creating any tasks. This did however mean that any variables which were accessed using this->SomeVariable became _this->SomeVariable.
So my example above now looks like this.
if (_serialPort1 != nullptr)
{
auto _this = this;
concurrency::create_task(WriteToSerialDeviceAsync(cancellationTokenSource_serialPort1->get_token(),
Arduino_Device.Outgoing_Bytes, PORT_1)).then([_this](concurrency::task<void> previousTask) {
try
{
previousTask.get();
}
catch (Platform::COMException^ ex)
{
_this->DataStreamWindow->Text += "\r\n!EXCEPTION CAUGHT! " + ex->Message;
}
});
}
Hope this is of use.
If so then why copying outside the task? You could do
if (_serialPort1 != nullptr)
{ concurrency::create_task(WriteToSerialDeviceAsync(cancellationTokenSource_serialPort1->get_token(),
Arduino_Device.Outgoing_Bytes, PORT_1)).then([_this = this](concurrency::task<void> previousTask) {
try
{
previousTask.get();
}
catch (Platform::COMException^ ex)
{
_this->DataStreamWindow->Text += "\r\n!EXCEPTION CAUGHT! " + ex->Message;
}
});
}
But based on your problem this is not the proper solution. You better find what's wrong with your project migration to VS 2019.

JavaFx controlsFX AutoCompletionEvent doesn't work

I want to handle the AutoCompletionEvent of the controlsFX 8.0.5 framework, but somehow it will be never fired?! When no suggestions are available there should be one entry with "new..." and when this entry is chosen I want to do something. Therefore I set an EventHandler.
I implemented the binding like this:
AutoCompletionBinding<String> bind = TextFields.bindAutoCompletion(tf, sr -> {
List<String> shownSuggestions = new ArrayList<String>();
for (Client c : suggestions) {
if (!sr.getUserText().isEmpty()
&& c.toString().toLowerCase().startsWith(sr.getUserText().toLowerCase())) {
shownSuggestions.add(c.toString());
}
if (shownSuggestions.isEmpty()) {
if (sr.getUserText().isEmpty()) {
shownSuggestions.add(NEW_PARTY);
} else {
shownSuggestions.add(sr.getUserText() + NEW_PARTY_WITH_NAME);
}
}
}
return shownSuggestions;
});
And this is my EventHandler:
bind.setOnAutoCompleted(new EventHandler<AutoCompletionEvent<String>>() {
#Override
public void handle(AutoCompletionEvent<String> event) {
if (event.getCompletion().equals(NEW_PARTY)) {
System.out.println("new party chosen");
} else if (event.getCompletion().endsWith(NEW_PARTY_WITH_NAME)) {
System.out.println("new party with input chosen");
}
event.consume();
}
});
But there is no output on the console.
Can someone please help me? I'm trying this for days now...
regards
There is a bug in controlsFX 8.0.5 causing that the event never gets fired. So the code is correct, but it's never called.
Bug report in controlsFX 8.0.5

How to Check internet is available or not in windows phone 7?

For internet checking i wrote the below lines of code.
bool isAvailable = NetworkInterface.GetIsNetworkAvailable();
if (isAvailable == true)
{
}
the above line always returning true if net is not available also.please tell me how to check the internet connection?
Check NetworkInterfaceType. If Internet is available then It
should be other than None
return (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType
!= Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None);
Reference Answer By vjsrinath: https://stackoverflow.com/questions/8341169/how-to-check-internetconnection-in-wp7
Hope this helps.
You can also try,
bool isAvailable = Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable;
Always check this in a thread, it takes some time
internal static bool IsNetworkAvailable()
{
bool _bhasNetworkConnection = false;
try
{
_bhasNetworkConnection = (NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.None);
}
catch
{
_bhasNetworkConnection = false;
}
return _bhasNetworkConnection;
}
Checking NetworkInterface.NetworkInterfaceType in the UI thread is "dangerous" as it is a blocking call! It is possible that this call takes up to 20 seconds...
Use the following method to have a non-blocking call:
public static void IsConnected(Action<bool> completed)
{
ThreadPool.QueueUserWorkItem(o =>
{
var type = NetworkInterface.NetworkInterfaceType;
completed(type != NetworkInterfaceType.None);
});
}
See https://xp-dev.com/svn/mytoolkit/MyToolkit.Wp8/Networking/NetworkState.cs (From my project page)
If you would like to change the UI in the completed action you have to run the logic in the UI thread. E.g.:
NetworkState.IsConnected(connected => {
if (connected)
{
Deployment.Current.Dispatcher.BeginInvoke(delegate {
// TODO add your UI logic
});
}
});
If you need a lot of connection checks, check out the NetworkStateTracker, which is my project:
https://xp-dev.com/svn/mytoolkit/MyToolkit.Wp8/Networking/NetworkStateTracker.cs

Resources