Merge revision 1594 changes:
- Fix completion status for asynchronous custom resource handler requests (issue #1066, issue #1187). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1750@1598 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
5bc6018fba
commit
fae6bcfce4
|
@ -5,11 +5,15 @@
|
|||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include "include/cef_runnable.h"
|
||||
#include "include/cef_stream.h"
|
||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/unittests/routing_test_handler.h"
|
||||
|
||||
// Comment out this define to disable the unit test timeout.
|
||||
#define TIMEOUT_ENABLED 1
|
||||
|
||||
namespace {
|
||||
|
||||
const char kTestUrl[] = "http://tests-srh/test.html";
|
||||
|
@ -96,6 +100,12 @@ class ReadTestHandler : public RoutingTestHandler {
|
|||
virtual void RunTest() OVERRIDE {
|
||||
// Create the browser.
|
||||
CreateBrowser(kTestUrl);
|
||||
|
||||
#if defined(TIMEOUT_ENABLED)
|
||||
// Time out the test after a reasonable period of time.
|
||||
CefPostDelayedTask(TID_UI,
|
||||
NewCefRunnableMethod(this, &ReadTestHandler::DestroyTest), 3000);
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
|
||||
|
@ -127,15 +137,31 @@ class ReadTestHandler : public RoutingTestHandler {
|
|||
const int actual_result = atoi(request.ToString().c_str());
|
||||
EXPECT_EQ(expected_result_, actual_result);
|
||||
|
||||
DestroyTest();
|
||||
DestroyTestIfDone();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
|
||||
bool isLoading,
|
||||
bool canGoBack,
|
||||
bool canGoForward) OVERRIDE {
|
||||
if (!isLoading) {
|
||||
got_on_loading_state_change_done_.yes();
|
||||
DestroyTestIfDone();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void DestroyTestIfDone() {
|
||||
if (got_on_query_ && got_on_loading_state_change_done_)
|
||||
DestroyTest();
|
||||
}
|
||||
|
||||
virtual void DestroyTest() OVERRIDE {
|
||||
EXPECT_TRUE(got_resource_handler_);
|
||||
EXPECT_TRUE(got_on_query_);
|
||||
EXPECT_TRUE(got_on_loading_state_change_done_);
|
||||
RoutingTestHandler::DestroyTest();
|
||||
}
|
||||
|
||||
|
@ -144,6 +170,7 @@ class ReadTestHandler : public RoutingTestHandler {
|
|||
int expected_result_;
|
||||
TrackCallback got_resource_handler_;
|
||||
TrackCallback got_on_query_;
|
||||
TrackCallback got_on_loading_state_change_done_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue