diff --git a/atom.gyp b/atom.gyp index 55be4abe9..4ee328c29 100644 --- a/atom.gyp +++ b/atom.gyp @@ -57,7 +57,6 @@ 'tests/cefclient/client_renderer.h', 'tests/cefclient/client_switches.cpp', 'tests/cefclient/client_switches.h', - 'tests/cefclient/resource_util.h', 'tests/cefclient/util.h', ], 'mac_bundle_resources': [ @@ -193,7 +192,6 @@ 'include/internal/cef_types_mac.h', 'tests/cefclient/cefclient_mac.mm', 'tests/cefclient/client_handler_mac.mm', - 'tests/cefclient/resource_util_mac.mm', ], }], [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', { @@ -282,8 +280,6 @@ 'tests/cefclient/client_switches.cpp', 'tests/cefclient/client_switches.h', 'tests/cefclient/process_helper_mac.cpp', - 'tests/cefclient/resource_util.h', - 'tests/cefclient/resource_util_mac.mm', 'tests/cefclient/util.h', ], # TODO(mark): Come up with a fancier way to do this. It should only diff --git a/tests/cefclient/binding_test.cpp b/tests/cefclient/binding_test.cpp deleted file mode 100644 index e3efa23f2..000000000 --- a/tests/cefclient/binding_test.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "cefclient/binding_test.h" - -#include -#include - -#include "include/wrapper/cef_stream_resource_handler.h" -#include "cefclient/resource_util.h" - -namespace binding_test { - -namespace { - -const char* kTestUrl = "http://tests/binding"; -const char* kMessageName = "binding_test"; - -// Handle messages in the browser process. -class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { - public: - ProcessMessageDelegate() { - } - - // From ClientHandler::ProcessMessageDelegate. - virtual bool OnProcessMessageReceived( - CefRefPtr handler, - CefRefPtr browser, - CefProcessId source_process, - CefRefPtr message) OVERRIDE { - std::string message_name = message->GetName(); - if (message_name == kMessageName) { - // Handle the message. - std::string result; - - CefRefPtr args = message->GetArgumentList(); - if (args->GetSize() > 0 && args->GetType(0) == VTYPE_STRING) { - // Our result is a reverse of the original message. - result = args->GetString(0); - std::reverse(result.begin(), result.end()); - } else { - result = "Invalid request"; - } - - // Send the result back to the render process. - CefRefPtr response = - CefProcessMessage::Create(kMessageName); - response->GetArgumentList()->SetString(0, result); - browser->SendProcessMessage(PID_RENDERER, response); - - return true; - } - - return false; - } - - IMPLEMENT_REFCOUNTING(ProcessMessageDelegate); -}; - -// Handle resource loading in the browser process. -class RequestDelegate: public ClientHandler::RequestDelegate { - public: - RequestDelegate() { - } - - // From ClientHandler::RequestDelegate. - virtual CefRefPtr GetResourceHandler( - CefRefPtr handler, - CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request) OVERRIDE { - std::string url = request->GetURL(); - if (url == kTestUrl) { - // Show the binding contents - CefRefPtr stream = - GetBinaryResourceReader("binding.html"); - ASSERT(stream.get()); - return new CefStreamResourceHandler("text/html", stream); - } - - return NULL; - } - - IMPLEMENT_REFCOUNTING(RequestDelegate); -}; - -} // namespace - -void CreateProcessMessageDelegates( - ClientHandler::ProcessMessageDelegateSet& delegates) { - delegates.insert(new ProcessMessageDelegate); -} - -void CreateRequestDelegates(ClientHandler::RequestDelegateSet& delegates) { - delegates.insert(new RequestDelegate); -} - -void RunTest(CefRefPtr browser) { - // Load the test URL. - browser->GetMainFrame()->LoadURL(kTestUrl); -} - -} // namespace binding_test diff --git a/tests/cefclient/binding_test.h b/tests/cefclient/binding_test.h deleted file mode 100644 index 3412fa2a1..000000000 --- a/tests/cefclient/binding_test.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_BINDING_TEST_H_ -#define CEF_TESTS_CEFCLIENT_BINDING_TEST_H_ -#pragma once - -#include "cefclient/client_app.h" -#include "cefclient/client_handler.h" - -namespace binding_test { - -// Delegate creation. Called from ClientApp and ClientHandler. -void CreateProcessMessageDelegates( - ClientHandler::ProcessMessageDelegateSet& delegates); -void CreateRequestDelegates(ClientHandler::RequestDelegateSet& delegates); - -// Run the test. -void RunTest(CefRefPtr browser); - -} // namespace binding_test - -#endif // CEF_TESTS_CEFCLIENT_BINDING_TEST_H_ diff --git a/tests/cefclient/cefclient.cpp b/tests/cefclient/cefclient.cpp index 43df24def..09c412657 100644 --- a/tests/cefclient/cefclient.cpp +++ b/tests/cefclient/cefclient.cpp @@ -15,7 +15,6 @@ #include "include/cef_web_plugin.h" #include "cefclient/client_handler.h" #include "cefclient/client_switches.h" -#include "cefclient/string_util.h" #include "cefclient/util.h" CefRefPtr g_handler; diff --git a/tests/cefclient/cefclient_mac.mm b/tests/cefclient/cefclient_mac.mm index 27d495206..13a7d055b 100644 --- a/tests/cefclient/cefclient_mac.mm +++ b/tests/cefclient/cefclient_mac.mm @@ -12,8 +12,6 @@ #include "include/cef_frame.h" #include "include/cef_runnable.h" #include "cefclient/client_handler.h" -#include "cefclient/resource_util.h" -#include "cefclient/string_util.h" // The global ClientHandler reference. extern CefRefPtr g_handler; diff --git a/tests/cefclient/client_handler.cpp b/tests/cefclient/client_handler.cpp index 5c94a6a17..a9247eb33 100644 --- a/tests/cefclient/client_handler.cpp +++ b/tests/cefclient/client_handler.cpp @@ -16,8 +16,6 @@ #include "cefclient/cefclient.h" #include "cefclient/client_renderer.h" #include "cefclient/client_switches.h" -#include "cefclient/resource_util.h" -#include "cefclient/string_util.h" // Custom menu command Ids. diff --git a/tests/cefclient/dom_test.cpp b/tests/cefclient/dom_test.cpp deleted file mode 100644 index 5002d6394..000000000 --- a/tests/cefclient/dom_test.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "cefclient/dom_test.h" - -#include -#include - -#include "include/cef_dom.h" -#include "cefclient/util.h" - -namespace dom_test { - -const char kTestUrl[] = "http://tests/domaccess"; - -namespace { - -const char* kMessageName = "DOMTest.Message"; - -class ClientDOMEventListener : public CefDOMEventListener { - public: - ClientDOMEventListener() { - } - - virtual void HandleEvent(CefRefPtr event) OVERRIDE { - CefRefPtr document = event->GetDocument(); - ASSERT(document.get()); - - std::stringstream ss; - - CefRefPtr button = event->GetTarget(); - ASSERT(button.get()); - std::string buttonValue = button->GetElementAttribute("value"); - ss << "You clicked the " << buttonValue.c_str() << " button. "; - - if (document->HasSelection()) { - std::string startName, endName; - - // Determine the start name by first trying to locate the "id" attribute - // and then defaulting to the tag name. - { - CefRefPtr node = document->GetSelectionStartNode(); - if (!node->IsElement()) - node = node->GetParent(); - if (node->IsElement() && node->HasElementAttribute("id")) - startName = node->GetElementAttribute("id"); - else - startName = node->GetName(); - } - - // Determine the end name by first trying to locate the "id" attribute - // and then defaulting to the tag name. - { - CefRefPtr node = document->GetSelectionEndNode(); - if (!node->IsElement()) - node = node->GetParent(); - if (node->IsElement() && node->HasElementAttribute("id")) - endName = node->GetElementAttribute("id"); - else - endName = node->GetName(); - } - - ss << "The selection is from " << - startName.c_str() << ":" << document->GetSelectionStartOffset() << - " to " << - endName.c_str() << ":" << document->GetSelectionEndOffset(); - } else { - ss << "Nothing is selected."; - } - - // Update the description. - CefRefPtr desc = document->GetElementById("description"); - ASSERT(desc.get()); - CefRefPtr text = desc->GetFirstChild(); - ASSERT(text.get()); - ASSERT(text->IsText()); - text->SetValue(ss.str()); - } - - IMPLEMENT_REFCOUNTING(ClientDOMEventListener); -}; - -class ClientDOMVisitor : public CefDOMVisitor { - public: - ClientDOMVisitor() { - } - - virtual void Visit(CefRefPtr document) OVERRIDE { - // Register a click listener for the button. - CefRefPtr button = document->GetElementById("button"); - ASSERT(button.get()); - button->AddEventListener("click", new ClientDOMEventListener(), false); - } - - IMPLEMENT_REFCOUNTING(ClientDOMVisitor); -}; - -class DOMRenderDelegate : public ClientApp::RenderDelegate { - public: - DOMRenderDelegate() { - } - - virtual bool OnProcessMessageReceived( - CefRefPtr app, - CefRefPtr browser, - CefProcessId source_process, - CefRefPtr message) OVERRIDE { - if (message->GetName() == kMessageName) { - // Visit the DOM to attach the event listener. - browser->GetMainFrame()->VisitDOM(new ClientDOMVisitor); - return true; - } - - return false; - } - - private: - IMPLEMENT_REFCOUNTING(DOMRenderDelegate); -}; - -} // namespace - -void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) { - delegates.insert(new DOMRenderDelegate); -} - -void RunTest(CefRefPtr browser) { - // Load the test URL. - browser->GetMainFrame()->LoadURL(kTestUrl); -} - -void OnLoadEnd(CefRefPtr browser) { - // Send a message to the render process to continue the test setup. - browser->SendProcessMessage(PID_RENDERER, - CefProcessMessage::Create(kMessageName)); -} - -} // namespace dom_test diff --git a/tests/cefclient/dom_test.h b/tests/cefclient/dom_test.h deleted file mode 100644 index 0bcee1749..000000000 --- a/tests/cefclient/dom_test.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_DOM_TEST_H_ -#define CEF_TESTS_CEFCLIENT_DOM_TEST_H_ -#pragma once - -#include "include/cef_base.h" -#include "cefclient/client_app.h" - -namespace dom_test { - -// The DOM test URL. -extern const char kTestUrl[]; - -// Create the render delegate. -void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates); - -// Run the test. -void RunTest(CefRefPtr browser); - -// Continue the test after the page has loaded. -void OnLoadEnd(CefRefPtr browser); - -} // namespace dom_test - -#endif // CEF_TESTS_CEFCLIENT_DOM_TEST_H_ diff --git a/tests/cefclient/res/binding.html b/tests/cefclient/res/binding.html deleted file mode 100644 index edb1f4a00..000000000 --- a/tests/cefclient/res/binding.html +++ /dev/null @@ -1,27 +0,0 @@ - - -Binding Test - - - - -
-Message: -
-
You should see the reverse of your message below: -
-
- - diff --git a/tests/cefclient/res/dialogs.html b/tests/cefclient/res/dialogs.html deleted file mode 100644 index 1bce8e475..000000000 --- a/tests/cefclient/res/dialogs.html +++ /dev/null @@ -1,45 +0,0 @@ - - -Dialog Test - - - -
-Click a button to show the associated dialog type. -
-
-
-

-
- - diff --git a/tests/cefclient/res/domaccess.html b/tests/cefclient/res/domaccess.html deleted file mode 100644 index 68ff69647..000000000 --- a/tests/cefclient/res/domaccess.html +++ /dev/null @@ -1,13 +0,0 @@ - - -

Select some portion of the below page content and click the "Describe Selection" button. The selected region will then be described below.

-

This is p1

-

This is p2

-

This is p3

-

This is p4

-
- -

The description will appear here.

-
- - diff --git a/tests/cefclient/res/localstorage.html b/tests/cefclient/res/localstorage.html deleted file mode 100644 index a794305b7..000000000 --- a/tests/cefclient/res/localstorage.html +++ /dev/null @@ -1,24 +0,0 @@ - - - -Click the "Add Line" button to add a line or the "Clear" button to clear.
-This data will persist across sessions if a cache path was specified.
- - -
- - - diff --git a/tests/cefclient/res/logo.png b/tests/cefclient/res/logo.png deleted file mode 100644 index 41dd728df..000000000 Binary files a/tests/cefclient/res/logo.png and /dev/null differ diff --git a/tests/cefclient/res/logoball.png b/tests/cefclient/res/logoball.png deleted file mode 100644 index ef115ca07..000000000 Binary files a/tests/cefclient/res/logoball.png and /dev/null differ diff --git a/tests/cefclient/res/xmlhttprequest.html b/tests/cefclient/res/xmlhttprequest.html deleted file mode 100644 index 638c63c82..000000000 --- a/tests/cefclient/res/xmlhttprequest.html +++ /dev/null @@ -1,19 +0,0 @@ - - - -
-URL: -
-
-
- - diff --git a/tests/cefclient/resource.h b/tests/cefclient/resource.h deleted file mode 100644 index dd6988e3b..000000000 --- a/tests/cefclient/resource.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by cefclient.rc -// -#define BINARY 256 -#define IDC_MYICON 2 -#define IDD_CEFCLIENT_DIALOG 102 -#define IDS_APP_TITLE 103 -#define IDD_ABOUTBOX 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 -#define IDI_CEFCLIENT 107 -#define IDI_SMALL 108 -#define IDC_CEFCLIENT 109 -#define IDR_MAINFRAME 128 -#define IDC_NAV_BACK 200 -#define IDC_NAV_FORWARD 201 -#define IDC_NAV_RELOAD 202 -#define IDC_NAV_STOP 203 -#define ID_WARN_CONSOLEMESSAGE 32000 -#define ID_WARN_DOWNLOADCOMPLETE 32001 -#define ID_WARN_DOWNLOADERROR 32002 -#define ID_TESTS_GETSOURCE 32760 -#define ID_TESTS_GETTEXT 32761 -#define ID_TESTS_POPUP 32762 -#define ID_TESTS_REQUEST 32763 -#define ID_TESTS_SCHEME_HANDLER 32764 -#define ID_TESTS_LOCALSTORAGE 32765 -#define ID_TESTS_ACCELERATED2DCANVAS 32766 -#define ID_TESTS_ACCELERATEDLAYERS 32767 -#define ID_TESTS_WEBGL 32768 -#define ID_TESTS_HTML5VIDEO 32769 -#define ID_TESTS_XMLHTTPREQUEST 32770 -#define ID_TESTS_DRAGDROP 32771 -#define ID_TESTS_GEOLOCATION 32772 -#define ID_TESTS_BINDING 32773 -#define ID_TESTS_DIALOGS 32774 -#define ID_TESTS_PLUGIN_INFO 32775 -#define ID_TESTS_DOM_ACCESS 32776 -#define ID_TESTS_ZOOM_IN 32777 -#define ID_TESTS_ZOOM_OUT 32778 -#define ID_TESTS_ZOOM_RESET 32779 -#define IDC_STATIC -1 -#define IDS_BINDING 1000 -#define IDS_DIALOGS 1001 -#define IDS_LOGO 1002 -#define IDS_LOGOBALL 1003 -#define IDS_LOCALSTORAGE 1004 -#define IDS_XMLHTTPREQUEST 1005 -#define IDS_DOMACCESS 1006 - -// Avoid files associated with MacOS -#define _X86_ - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 130 -#define _APS_NEXT_COMMAND_VALUE 32774 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif diff --git a/tests/cefclient/resource_util.h b/tests/cefclient/resource_util.h deleted file mode 100644 index c382196f4..000000000 --- a/tests/cefclient/resource_util.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ -#define CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ -#pragma once - -#include "include/cef_base.h" - -class CefStreamReader; - -#if defined(OS_WIN) - -#include "cefclient/resource.h" - -// Load a resource of type BINARY -bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes); -CefRefPtr GetBinaryResourceReader(int binaryId); - -#elif defined(OS_MACOSX) || defined(OS_POSIX) - -#include // NOLINT(build/include_order) - -// Load the resource with the specified name. -bool LoadBinaryResource(const char* resource_name, std::string& resource_data); - -#endif - -CefRefPtr GetBinaryResourceReader(const char* resource_name); - -#endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ diff --git a/tests/cefclient/resource_util_linux.cpp b/tests/cefclient/resource_util_linux.cpp deleted file mode 100644 index 66b46267d..000000000 --- a/tests/cefclient/resource_util_linux.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "cefclient/resource_util.h" -#include -#include -#include "include/cef_stream.h" -#include "cefclient/util.h" - -bool GetResourceDir(std::string& dir) { - char buff[1024]; - - // Retrieve the executable path. - ssize_t len = readlink("/proc/self/exe", buff, sizeof(buff)-1); - if (len == -1) - return false; - - buff[len] = 0; - - // Remove the executable name from the path. - char* pos = strrchr(buff, '/'); - if (!pos) - return false; - - // Add "files" to the path. - strcpy(pos+1, "files"); // NOLINT(runtime/printf) - dir = std::string(buff); - return true; -} - -bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { - std::string path; - if (!GetResourceDir(path)) - return false; - - path.append("/"); - path.append(resource_name); - - FILE* f = fopen(path.c_str(), "rb"); - if (!f) - return false; - - size_t bytes_read; - char buff[1024*8]; - - do { - bytes_read = fread(buff, 1, sizeof(buff)-1, f); - if (bytes_read > 0) - resource_data.append(buff, bytes_read); - } while (bytes_read > 0); - - fclose(f); - return true; -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { - std::string path; - if (!GetResourceDir(path)) - return NULL; - - path.append("/"); - path.append(resource_name); - - return CefStreamReader::CreateForFile(path); -} diff --git a/tests/cefclient/resource_util_mac.mm b/tests/cefclient/resource_util_mac.mm deleted file mode 100644 index 98cfd8605..000000000 --- a/tests/cefclient/resource_util_mac.mm +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import -#include -#include -#include "cefclient/resource_util.h" -#include "include/cef_stream.h" -#include "cefclient/util.h" - -namespace { - -bool AmIBundled() { - // Implementation adapted from Chromium's base/mac/foundation_util.mm - ProcessSerialNumber psn = {0, kCurrentProcess}; - - FSRef fsref; - OSStatus pbErr; - if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { - ASSERT(false); - return false; - } - - FSCatalogInfo info; - OSErr fsErr; - if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, - NULL, NULL, NULL)) != noErr) { - ASSERT(false); - return false; - } - - return (info.nodeFlags & kFSNodeIsDirectoryMask); -} - -bool GetResourceDir(std::string& dir) { - // Implementation adapted from Chromium's base/base_path_mac.mm - if (AmIBundled()) { - // Retrieve the executable directory. - uint32_t pathSize = 0; - _NSGetExecutablePath(NULL, &pathSize); - if (pathSize > 0) { - dir.resize(pathSize); - _NSGetExecutablePath(const_cast(dir.c_str()), &pathSize); - } - - // Trim executable name up to the last separator - std::string::size_type last_separator = dir.find_last_of("/"); - dir.resize(last_separator); - dir.append("/../Resources"); - return true; - } else { - // TODO: Provide unbundled path - ASSERT(false); - return false; - } -} - -bool ReadFileToString(const char* path, std::string& data) { - // Implementation adapted from base/file_util.cc - FILE* file = fopen(path, "rb"); - if (!file) - return false; - - char buf[1 << 16]; - size_t len; - while ((len = fread(buf, 1, sizeof(buf), file)) > 0) - data.append(buf, len); - fclose(file); - - return true; -} - -} // namespace - -bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { - std::string path; - if (!GetResourceDir(path)) - return false; - - path.append("/"); - path.append(resource_name); - - return ReadFileToString(path.c_str(), resource_data); -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { - std::string path; - if (!GetResourceDir(path)) - return NULL; - - path.append("/"); - path.append(resource_name); - - return CefStreamReader::CreateForFile(path); -} diff --git a/tests/cefclient/resource_util_win.cpp b/tests/cefclient/resource_util_win.cpp deleted file mode 100644 index 8482ac954..000000000 --- a/tests/cefclient/resource_util_win.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "cefclient/resource_util.h" -#include "include/cef_stream.h" -#include "include/wrapper/cef_byte_read_handler.h" -#include "cefclient/util.h" - -#if defined(OS_WIN) - -bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) { - extern HINSTANCE hInst; - HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(binaryId), - MAKEINTRESOURCE(256)); - if (hRes) { - HGLOBAL hGlob = LoadResource(hInst, hRes); - if (hGlob) { - dwSize = SizeofResource(hInst, hRes); - pBytes = (LPBYTE)LockResource(hGlob); - if (dwSize > 0 && pBytes) - return true; - } - } - - return false; -} - -CefRefPtr GetBinaryResourceReader(int binaryId) { - DWORD dwSize; - LPBYTE pBytes; - - if (LoadBinaryResource(binaryId, dwSize, pBytes)) { - return CefStreamReader::CreateForHandler( - new CefByteReadHandler(pBytes, dwSize, NULL)); - } - - ASSERT(FALSE); // The resource should be found. - return NULL; -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { - // Map of resource labels to BINARY id values. - static struct _resource_map { - char* name; - int id; - } resource_map[] = { - {"binding.html", IDS_BINDING}, - {"dialogs.html", IDS_DIALOGS}, - {"domaccess.html", IDS_DOMACCESS}, - {"localstorage.html", IDS_LOCALSTORAGE}, - {"xmlhttprequest.html", IDS_XMLHTTPREQUEST}, - }; - - for (int i = 0; i < sizeof(resource_map)/sizeof(_resource_map); ++i) { - if (!strcmp(resource_map[i].name, resource_name)) - return GetBinaryResourceReader(resource_map[i].id); - } - - ASSERT(FALSE); // The resource should be found. - return NULL; -} - -#endif // OS_WIN diff --git a/tests/cefclient/scheme_test.cpp b/tests/cefclient/scheme_test.cpp deleted file mode 100644 index ee33a4389..000000000 --- a/tests/cefclient/scheme_test.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "cefclient/scheme_test.h" -#include -#include -#include "include/cef_browser.h" -#include "include/cef_callback.h" -#include "include/cef_frame.h" -#include "include/cef_resource_handler.h" -#include "include/cef_response.h" -#include "include/cef_request.h" -#include "include/cef_scheme.h" -#include "cefclient/resource_util.h" -#include "cefclient/string_util.h" -#include "cefclient/util.h" - -#if defined(OS_WIN) -#include "cefclient/resource.h" -#endif - -namespace scheme_test { - -namespace { - -// Implementation of the schema handler for client:// requests. -class ClientSchemeHandler : public CefResourceHandler { - public: - ClientSchemeHandler() : offset_(0) {} - - virtual bool ProcessRequest(CefRefPtr request, - CefRefPtr callback) - OVERRIDE { - REQUIRE_IO_THREAD(); - - bool handled = false; - - AutoLock lock_scope(this); - - std::string url = request->GetURL(); - if (strstr(url.c_str(), "handler.html") != NULL) { - // Build the response html - data_ = "Client Scheme Handler" - "This contents of this page page are served by the " - "ClientSchemeHandler class handling the client:// protocol." - "
You should see an image:" - "
";
-
-      // Output a string representation of the request
-      std::string dump;
-      DumpRequestContents(request, dump);
-      data_.append(dump);
-
-      data_.append("

Try the test form:" - "
" - "" - "" - "" - "
"); - - handled = true; - - // Set the resulting mime type - mime_type_ = "text/html"; - } else if (strstr(url.c_str(), "client.png") != NULL) { - // Load the response image -#if defined(OS_WIN) - DWORD dwSize; - LPBYTE pBytes; - if (LoadBinaryResource(IDS_LOGO, dwSize, pBytes)) { - data_ = std::string(reinterpret_cast(pBytes), dwSize); - handled = true; - // Set the resulting mime type - mime_type_ = "image/jpg"; - } -#elif defined(OS_MACOSX) || defined(OS_LINUX) - if (LoadBinaryResource("logo.png", data_)) { - handled = true; - // Set the resulting mime type - mime_type_ = "image/png"; - } -#else -#error "Unsupported platform" -#endif - } - - if (handled) { - // Indicate the headers are available. - callback->Continue(); - return true; - } - - return false; - } - - virtual void GetResponseHeaders(CefRefPtr response, - int64& response_length, - CefString& redirectUrl) OVERRIDE { - REQUIRE_IO_THREAD(); - - ASSERT(!data_.empty()); - - response->SetMimeType(mime_type_); - response->SetStatus(200); - - // Set the resulting response length - response_length = data_.length(); - } - - virtual void Cancel() OVERRIDE { - REQUIRE_IO_THREAD(); - } - - virtual bool ReadResponse(void* data_out, - int bytes_to_read, - int& bytes_read, - CefRefPtr callback) - OVERRIDE { - REQUIRE_IO_THREAD(); - - bool has_data = false; - bytes_read = 0; - - AutoLock lock_scope(this); - - if (offset_ < data_.length()) { - // Copy the next block of data into the buffer. - int transfer_size = - std::min(bytes_to_read, static_cast(data_.length() - offset_)); - memcpy(data_out, data_.c_str() + offset_, transfer_size); - offset_ += transfer_size; - - bytes_read = transfer_size; - has_data = true; - } - - return has_data; - } - - private: - std::string data_; - std::string mime_type_; - size_t offset_; - - IMPLEMENT_REFCOUNTING(ClientSchemeHandler); - IMPLEMENT_LOCKING(ClientSchemeHandler); -}; - -// Implementation of the factory for for creating schema handlers. -class ClientSchemeHandlerFactory : public CefSchemeHandlerFactory { - public: - // Return a new scheme handler instance to handle the request. - virtual CefRefPtr Create(CefRefPtr browser, - CefRefPtr frame, - const CefString& scheme_name, - CefRefPtr request) - OVERRIDE { - REQUIRE_IO_THREAD(); - return new ClientSchemeHandler(); - } - - IMPLEMENT_REFCOUNTING(ClientSchemeHandlerFactory); -}; - -} // namespace - -void RegisterCustomSchemes(CefRefPtr registrar, - std::vector& cookiable_schemes) { - registrar->AddCustomScheme("client", true, false, false); -} - -void InitTest() { - CefRegisterSchemeHandlerFactory("client", "tests", - new ClientSchemeHandlerFactory()); -} - -void RunTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL("client://tests/handler.html"); -} - -} // namespace scheme_test diff --git a/tests/cefclient/scheme_test.h b/tests/cefclient/scheme_test.h deleted file mode 100644 index 724843a92..000000000 --- a/tests/cefclient/scheme_test.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_SCHEME_TEST_H_ -#define CEF_TESTS_CEFCLIENT_SCHEME_TEST_H_ -#pragma once - -#include -#include "include/cef_base.h" - -class CefBrowser; -class CefSchemeRegistrar; - -namespace scheme_test { - -// Register the scheme. -void RegisterCustomSchemes(CefRefPtr registrar, - std::vector& cookiable_schemes); - -// Create the scheme handler. -void InitTest(); - -// Run the test. -void RunTest(CefRefPtr browser); - -} // namespace scheme_test - -#endif // CEF_TESTS_CEFCLIENT_SCHEME_TEST_H_ diff --git a/tests/cefclient/string_util.cpp b/tests/cefclient/string_util.cpp deleted file mode 100644 index 35bf2ec19..000000000 --- a/tests/cefclient/string_util.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "cefclient/string_util.h" -#include -#include -#include "include/cef_request.h" diff --git a/tests/cefclient/string_util.h b/tests/cefclient/string_util.h deleted file mode 100644 index 6e679f812..000000000 --- a/tests/cefclient/string_util.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_STRING_UTIL_H_ -#define CEF_TESTS_CEFCLIENT_STRING_UTIL_H_ -#pragma once - -#include -#include "include/cef_base.h" - -class CefRequest; - -#endif // CEF_TESTS_CEFCLIENT_STRING_UTIL_H_ diff --git a/tests/unittests/client_app_delegates.cc b/tests/unittests/client_app_delegates.cc deleted file mode 100644 index e47e97698..000000000 --- a/tests/unittests/client_app_delegates.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "tests/cefclient/client_app.h" - -// static -void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) { - // Bring in the process message tests. - extern void CreateProcessMessageRendererTests( - ClientApp::RenderDelegateSet& delegates); - CreateProcessMessageRendererTests(delegates); - - // Bring in the V8 tests. - extern void CreateV8RendererTests(RenderDelegateSet& delegates); - CreateV8RendererTests(delegates); - - // Bring in the DOM tests. - extern void CreateDOMRendererTests(RenderDelegateSet& delegates); - CreateDOMRendererTests(delegates); - - // Bring in the URLRequest tests. - extern void CreateURLRequestRendererTests(RenderDelegateSet& delegates); - CreateURLRequestRendererTests(delegates); -} - -// static -void ClientApp::RegisterCustomSchemes( - CefRefPtr registrar, - std::vector& cookiable_schemes) { - // Bring in the scheme handler tests. - extern void RegisterSchemeHandlerCustomSchemes( - CefRefPtr registrar, - std::vector& cookiable_schemes); - RegisterSchemeHandlerCustomSchemes(registrar, cookiable_schemes); - - // Bring in the cookie tests. - extern void RegisterCookieCustomSchemes( - CefRefPtr registrar, - std::vector& cookiable_schemes); - RegisterCookieCustomSchemes(registrar, cookiable_schemes); - - // Bring in the URLRequest tests. - extern void RegisterURLRequestCustomSchemes( - CefRefPtr registrar, - std::vector& cookiable_schemes); - RegisterURLRequestCustomSchemes(registrar, cookiable_schemes); -} diff --git a/tests/unittests/command_line_unittest.cc b/tests/unittests/command_line_unittest.cc deleted file mode 100644 index 19c4b47b6..000000000 --- a/tests/unittests/command_line_unittest.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "include/cef_command_line.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -void VerifyCommandLine(CefRefPtr command_line) { - std::string program = command_line->GetProgram(); - EXPECT_EQ("test.exe", program); - - EXPECT_TRUE(command_line->HasSwitches()); - - EXPECT_TRUE(command_line->HasSwitch("switch1")); - std::string switch1 = command_line->GetSwitchValue("switch1"); - EXPECT_EQ("", switch1); - EXPECT_TRUE(command_line->HasSwitch("switch2")); - std::string switch2 = command_line->GetSwitchValue("switch2"); - EXPECT_EQ("val2", switch2); - EXPECT_TRUE(command_line->HasSwitch("switch3")); - std::string switch3 = command_line->GetSwitchValue("switch3"); - EXPECT_EQ("val3", switch3); - EXPECT_TRUE(command_line->HasSwitch("switch4")); - std::string switch4 = command_line->GetSwitchValue("switch4"); - EXPECT_EQ("val 4", switch4); - EXPECT_FALSE(command_line->HasSwitch("switchnoexist")); - - CefCommandLine::SwitchMap switches; - command_line->GetSwitches(switches); - EXPECT_EQ((size_t)4, switches.size()); - - bool has1 = false, has2 = false, has3 = false, has4 = false; - - CefCommandLine::SwitchMap::const_iterator it = switches.begin(); - for (; it != switches.end(); ++it) { - std::string name = it->first; - std::string val = it->second; - - if (name == "switch1") { - has1 = true; - EXPECT_EQ("", val); - } else if (name == "switch2") { - has2 = true; - EXPECT_EQ("val2", val); - } else if (name == "switch3") { - has3 = true; - EXPECT_EQ("val3", val); - } else if (name == "switch4") { - has4 = true; - EXPECT_EQ("val 4", val); - } - } - - EXPECT_TRUE(has1); - EXPECT_TRUE(has2); - EXPECT_TRUE(has3); - EXPECT_TRUE(has4); - - EXPECT_TRUE(command_line->HasArguments()); - - CefCommandLine::ArgumentList args; - command_line->GetArguments(args); - EXPECT_EQ((size_t)2, args.size()); - std::string arg0 = args[0]; - EXPECT_EQ("arg1", arg0); - std::string arg1 = args[1]; - EXPECT_EQ("arg 2", arg1); - - command_line->Reset(); - EXPECT_FALSE(command_line->HasSwitches()); - EXPECT_FALSE(command_line->HasArguments()); - std::string cur_program = command_line->GetProgram(); - EXPECT_EQ(program, cur_program); -} - -} // namespace - -// Test creating a command line from argc/argv or string. -TEST(CommandLineTest, Init) { - CefRefPtr command_line = CefCommandLine::CreateCommandLine(); - EXPECT_TRUE(command_line.get() != NULL); - -#if defined(OS_WIN) - command_line->InitFromString("test.exe --switch1 -switch2=val2 /switch3=val3 " - "-switch4=\"val 4\" arg1 \"arg 2\""); -#else - const char* args[] = { - "test.exe", - "--switch1", - "-switch2=val2", - "-switch3=val3", - "-switch4=val 4", - "arg1", - "arg 2" - }; - command_line->InitFromArgv(sizeof(args) / sizeof(char*), args); -#endif - - VerifyCommandLine(command_line); -} - -// Test creating a command line using set and append methods. -TEST(CommandLineTest, Manual) { - CefRefPtr command_line = CefCommandLine::CreateCommandLine(); - EXPECT_TRUE(command_line.get() != NULL); - - command_line->SetProgram("test.exe"); - command_line->AppendSwitch("switch1"); - command_line->AppendSwitchWithValue("switch2", "val2"); - command_line->AppendSwitchWithValue("switch3", "val3"); - command_line->AppendSwitchWithValue("switch4", "val 4"); - command_line->AppendArgument("arg1"); - command_line->AppendArgument("arg 2"); - - VerifyCommandLine(command_line); -} diff --git a/tests/unittests/cookie_unittest.cc b/tests/unittests/cookie_unittest.cc deleted file mode 100644 index 9b2ca26f5..000000000 --- a/tests/unittests/cookie_unittest.cc +++ /dev/null @@ -1,962 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include -#include "include/cef_cookie.h" -#include "include/cef_runnable.h" -#include "include/cef_scheme.h" -#include "tests/unittests/test_handler.h" -#include "tests/unittests/test_suite.h" -#include "base/scoped_temp_dir.h" -#include "base/synchronization/waitable_event.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -const char* kTestUrl = "http://www.test.com/path/to/cookietest/foo.html"; -const char* kTestDomain = "www.test.com"; -const char* kTestPath = "/path/to/cookietest"; - -typedef std::vector CookieVector; - -void IOT_Set(CefRefPtr manager, - const CefString& url, CookieVector* cookies, - base::WaitableEvent* event) { - CookieVector::const_iterator it = cookies->begin(); - for (; it != cookies->end(); ++it) - EXPECT_TRUE(manager->SetCookie(url, *it)); - event->Signal(); -} - -void IOT_Delete(CefRefPtr manager, - const CefString& url, const CefString& cookie_name, - base::WaitableEvent* event) { - EXPECT_TRUE(manager->DeleteCookies(url, cookie_name)); - event->Signal(); -} - -class TestVisitor : public CefCookieVisitor { - public: - TestVisitor(CookieVector* cookies, bool deleteCookies, - base::WaitableEvent* event) - : cookies_(cookies), - delete_cookies_(deleteCookies), - event_(event) { - } - virtual ~TestVisitor() { - event_->Signal(); - } - - virtual bool Visit(const CefCookie& cookie, int count, int total, - bool& deleteCookie) { - cookies_->push_back(cookie); - if (delete_cookies_) - deleteCookie = true; - return true; - } - - CookieVector* cookies_; - bool delete_cookies_; - base::WaitableEvent* event_; - - IMPLEMENT_REFCOUNTING(TestVisitor); -}; - -// Set the cookies. -void SetCookies(CefRefPtr manager, - const CefString& url, CookieVector& cookies, - base::WaitableEvent& event) { - CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Set, manager, url, - &cookies, &event)); - event.Wait(); -} - -// Delete the cookie. -void DeleteCookies(CefRefPtr manager, - const CefString& url, const CefString& cookie_name, - base::WaitableEvent& event) { - CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Delete, manager, url, - cookie_name, &event)); - event.Wait(); -} - -// Create a test cookie. If |withDomain| is true a domain cookie will be -// created, otherwise a host cookie will be created. -void CreateCookie(CefRefPtr manager, - CefCookie& cookie, bool withDomain, - base::WaitableEvent& event) { - CefString(&cookie.name).FromASCII("my_cookie"); - CefString(&cookie.value).FromASCII("My Value"); - if (withDomain) - CefString(&cookie.domain).FromASCII(kTestDomain); - CefString(&cookie.path).FromASCII(kTestPath); - cookie.has_expires = true; - cookie.expires.year = 2200; - cookie.expires.month = 4; - cookie.expires.day_of_week = 5; - cookie.expires.day_of_month = 11; - - CookieVector cookies; - cookies.push_back(cookie); - - SetCookies(manager, kTestUrl, cookies, event); -} - -// Retrieve the test cookie. If |withDomain| is true check that the cookie -// is a domain cookie, otherwise a host cookie. if |deleteCookies| is true -// the cookie will be deleted when it's retrieved. -void GetCookie(CefRefPtr manager, - const CefCookie& cookie, bool withDomain, - base::WaitableEvent& event, bool deleteCookies) { - CookieVector cookies; - - // Get the cookie and delete it. - EXPECT_TRUE(manager->VisitUrlCookies(kTestUrl, false, - new TestVisitor(&cookies, deleteCookies, &event))); - event.Wait(); - - EXPECT_EQ((CookieVector::size_type)1, cookies.size()); - - const CefCookie& cookie_read = cookies[0]; - EXPECT_EQ(CefString(&cookie_read.name), "my_cookie"); - EXPECT_EQ(CefString(&cookie_read.value), "My Value"); - if (withDomain) - EXPECT_EQ(CefString(&cookie_read.domain), ".www.test.com"); - else - EXPECT_EQ(CefString(&cookie_read.domain), kTestDomain); - EXPECT_EQ(CefString(&cookie_read.path), kTestPath); - EXPECT_TRUE(cookie_read.has_expires); - EXPECT_EQ(cookie.expires.year, cookie_read.expires.year); - EXPECT_EQ(cookie.expires.month, cookie_read.expires.month); - EXPECT_EQ(cookie.expires.day_of_week, cookie_read.expires.day_of_week); - EXPECT_EQ(cookie.expires.day_of_month, cookie_read.expires.day_of_month); - EXPECT_EQ(cookie.expires.hour, cookie_read.expires.hour); - EXPECT_EQ(cookie.expires.minute, cookie_read.expires.minute); - EXPECT_EQ(cookie.expires.second, cookie_read.expires.second); - EXPECT_EQ(cookie.expires.millisecond, cookie_read.expires.millisecond); -} - -// Visit URL cookies. -void VisitUrlCookies(CefRefPtr manager, - const CefString& url, - bool includeHttpOnly, - CookieVector& cookies, - bool deleteCookies, - base::WaitableEvent& event) { - EXPECT_TRUE(manager->VisitUrlCookies(url, includeHttpOnly, - new TestVisitor(&cookies, deleteCookies, &event))); - event.Wait(); -} - -// Visit all cookies. -void VisitAllCookies(CefRefPtr manager, - CookieVector& cookies, - bool deleteCookies, - base::WaitableEvent& event) { - EXPECT_TRUE(manager->VisitAllCookies( - new TestVisitor(&cookies, deleteCookies, &event))); - event.Wait(); -} - -// Verify that no cookies exist. If |withUrl| is true it will only check for -// cookies matching the URL. -void VerifyNoCookies(CefRefPtr manager, - base::WaitableEvent& event, bool withUrl) { - CookieVector cookies; - - // Verify that the cookie has been deleted. - if (withUrl) { - EXPECT_TRUE(manager->VisitUrlCookies(kTestUrl, false, - new TestVisitor(&cookies, false, &event))); - } else { - EXPECT_TRUE(manager->VisitAllCookies( - new TestVisitor(&cookies, false, &event))); - } - event.Wait(); - - EXPECT_EQ((CookieVector::size_type)0, cookies.size()); -} - -// Delete all system cookies. -void DeleteAllCookies(CefRefPtr manager, - base::WaitableEvent& event) { - CefPostTask(TID_IO, NewCefRunnableFunction(IOT_Delete, manager, CefString(), - CefString(), &event)); - event.Wait(); -} - -void TestDomainCookie(CefRefPtr manager) { - base::WaitableEvent event(false, false); - CefCookie cookie; - - // Create a domain cookie. - CreateCookie(manager, cookie, true, event); - - // Retrieve, verify and delete the domain cookie. - GetCookie(manager, cookie, true, event, true); - - // Verify that the cookie was deleted. - VerifyNoCookies(manager, event, true); -} - -void TestHostCookie(CefRefPtr manager) { - base::WaitableEvent event(false, false); - CefCookie cookie; - - // Create a host cookie. - CreateCookie(manager, cookie, false, event); - - // Retrieve, verify and delete the host cookie. - GetCookie(manager, cookie, false, event, true); - - // Verify that the cookie was deleted. - VerifyNoCookies(manager, event, true); -} - -void TestMultipleCookies(CefRefPtr manager) { - base::WaitableEvent event(false, false); - std::stringstream ss; - int i; - - CookieVector cookies; - - const int kNumCookies = 4; - - // Create the cookies. - for (i = 0; i < kNumCookies; i++) { - CefCookie cookie; - - ss << "my_cookie" << i; - CefString(&cookie.name).FromASCII(ss.str().c_str()); - ss.str(""); - ss << "My Value " << i; - CefString(&cookie.value).FromASCII(ss.str().c_str()); - ss.str(""); - - cookies.push_back(cookie); - } - - // Set the cookies. - SetCookies(manager, kTestUrl, cookies, event); - cookies.clear(); - - // Get the cookies without deleting them. - VisitUrlCookies(manager, kTestUrl, false, cookies, false, event); - - EXPECT_EQ((CookieVector::size_type)kNumCookies, cookies.size()); - - CookieVector::const_iterator it = cookies.begin(); - for (i = 0; it != cookies.end(); ++it, ++i) { - const CefCookie& cookie = *it; - - ss << "my_cookie" << i; - EXPECT_EQ(CefString(&cookie.name), ss.str()); - ss.str(""); - ss << "My Value " << i; - EXPECT_EQ(CefString(&cookie.value), ss.str()); - ss.str(""); - } - - cookies.clear(); - - // Delete the 2nd cookie. - DeleteCookies(manager, kTestUrl, CefString("my_cookie1"), event); - - // Verify that the cookie has been deleted. - VisitUrlCookies(manager, kTestUrl, false, cookies, false, event); - - EXPECT_EQ((CookieVector::size_type)3, cookies.size()); - EXPECT_EQ(CefString(&cookies[0].name), "my_cookie0"); - EXPECT_EQ(CefString(&cookies[1].name), "my_cookie2"); - EXPECT_EQ(CefString(&cookies[2].name), "my_cookie3"); - - cookies.clear(); - - // Delete the rest of the cookies. - DeleteCookies(manager, kTestUrl, CefString(), event); - - // Verify that the cookies have been deleted. - VisitUrlCookies(manager, kTestUrl, false, cookies, false, event); - - EXPECT_EQ((CookieVector::size_type)0, cookies.size()); - - // Create the cookies. - for (i = 0; i < kNumCookies; i++) { - CefCookie cookie; - - ss << "my_cookie" << i; - CefString(&cookie.name).FromASCII(ss.str().c_str()); - ss.str(""); - ss << "My Value " << i; - CefString(&cookie.value).FromASCII(ss.str().c_str()); - ss.str(""); - - cookies.push_back(cookie); - } - - // Delete all of the cookies using the visitor. - VisitUrlCookies(manager, kTestUrl, false, cookies, true, event); - - cookies.clear(); - - // Verify that the cookies have been deleted. - VisitUrlCookies(manager, kTestUrl, false, cookies, false, event); - - EXPECT_EQ((CookieVector::size_type)0, cookies.size()); -} - -void TestAllCookies(CefRefPtr manager) { - base::WaitableEvent event(false, false); - CookieVector cookies; - - // Delete all system cookies just in case something is left over from a - // different test. - DeleteCookies(manager, CefString(), CefString(), event); - - // Verify that all system cookies have been deleted. - VisitAllCookies(manager, cookies, false, event); - - EXPECT_EQ((CookieVector::size_type)0, cookies.size()); - - // Create cookies with 2 separate hosts. - CefCookie cookie1; - const char* kUrl1 = "http://www.foo.com"; - CefString(&cookie1.name).FromASCII("my_cookie1"); - CefString(&cookie1.value).FromASCII("My Value 1"); - - cookies.push_back(cookie1); - SetCookies(manager, kUrl1, cookies, event); - cookies.clear(); - - CefCookie cookie2; - const char* kUrl2 = "http://www.bar.com"; - CefString(&cookie2.name).FromASCII("my_cookie2"); - CefString(&cookie2.value).FromASCII("My Value 2"); - - cookies.push_back(cookie2); - SetCookies(manager, kUrl2, cookies, event); - cookies.clear(); - - // Verify that all system cookies can be retrieved. - VisitAllCookies(manager, cookies, false, event); - - EXPECT_EQ((CookieVector::size_type)2, cookies.size()); - EXPECT_EQ(CefString(&cookies[0].name), "my_cookie1"); - EXPECT_EQ(CefString(&cookies[0].value), "My Value 1"); - EXPECT_EQ(CefString(&cookies[0].domain), "www.foo.com"); - EXPECT_EQ(CefString(&cookies[1].name), "my_cookie2"); - EXPECT_EQ(CefString(&cookies[1].value), "My Value 2"); - EXPECT_EQ(CefString(&cookies[1].domain), "www.bar.com"); - cookies.clear(); - - // Verify that the cookies can be retrieved separately. - VisitUrlCookies(manager, kUrl1, false, cookies, false, event); - - EXPECT_EQ((CookieVector::size_type)1, cookies.size()); - EXPECT_EQ(CefString(&cookies[0].name), "my_cookie1"); - EXPECT_EQ(CefString(&cookies[0].value), "My Value 1"); - EXPECT_EQ(CefString(&cookies[0].domain), "www.foo.com"); - cookies.clear(); - - VisitUrlCookies(manager, kUrl2, false, cookies, false, event); - - EXPECT_EQ((CookieVector::size_type)1, cookies.size()); - EXPECT_EQ(CefString(&cookies[0].name), "my_cookie2"); - EXPECT_EQ(CefString(&cookies[0].value), "My Value 2"); - EXPECT_EQ(CefString(&cookies[0].domain), "www.bar.com"); - cookies.clear(); - - // Delete all of the system cookies. - DeleteAllCookies(manager, event); - - // Verify that all system cookies have been deleted. - VerifyNoCookies(manager, event, false); -} - -void TestChangeDirectory(CefRefPtr manager, - const CefString& original_dir) { - base::WaitableEvent event(false, false); - CefCookie cookie; - - ScopedTempDir temp_dir; - - // Create a new temporary directory. - EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); - - // Delete all of the system cookies. - DeleteAllCookies(manager, event); - - // Set the new temporary directory as the storage location. - EXPECT_TRUE(manager->SetStoragePath(temp_dir.path().value())); - - // Wait for the storage location change to complete on the IO thread. - WaitForIOThread(); - - // Verify that no cookies exist. - VerifyNoCookies(manager, event, true); - - // Create a domain cookie. - CreateCookie(manager, cookie, true, event); - - // Retrieve and verify the domain cookie. - GetCookie(manager, cookie, true, event, false); - - // Restore the original storage location. - EXPECT_TRUE(manager->SetStoragePath(original_dir)); - - // Wait for the storage location change to complete on the IO thread. - WaitForIOThread(); - - // Verify that no cookies exist. - VerifyNoCookies(manager, event, true); - - // Set the new temporary directory as the storage location. - EXPECT_TRUE(manager->SetStoragePath(temp_dir.path().value())); - - // Wait for the storage location change to complete on the IO thread. - WaitForIOThread(); - - // Retrieve and verify the domain cookie that was set previously. - GetCookie(manager, cookie, true, event, false); - - // Restore the original storage location. - EXPECT_TRUE(manager->SetStoragePath(original_dir)); - - // Wait for the storage location change to complete on the IO thread. - WaitForIOThread(); -} - -} // namespace - -// Test creation of a domain cookie. -TEST(CookieTest, DomainCookieGlobal) { - CefRefPtr manager = CefCookieManager::GetGlobalManager(); - EXPECT_TRUE(manager.get()); - - TestDomainCookie(manager); -} - -// Test creation of a domain cookie. -TEST(CookieTest, DomainCookieInMemory) { - CefRefPtr manager = - CefCookieManager::CreateManager(CefString()); - EXPECT_TRUE(manager.get()); - - TestDomainCookie(manager); -} - -// Test creation of a domain cookie. -TEST(CookieTest, DomainCookieOnDisk) { - ScopedTempDir temp_dir; - - // Create a new temporary directory. - EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); - - CefRefPtr manager = - CefCookieManager::CreateManager(temp_dir.path().value()); - EXPECT_TRUE(manager.get()); - - TestDomainCookie(manager); -} - -// Test creation of a host cookie. -TEST(CookieTest, HostCookieGlobal) { - CefRefPtr manager = CefCookieManager::GetGlobalManager(); - EXPECT_TRUE(manager.get()); - - TestHostCookie(manager); -} - -// Test creation of a host cookie. -TEST(CookieTest, HostCookieInMemory) { - CefRefPtr manager = - CefCookieManager::CreateManager(CefString()); - EXPECT_TRUE(manager.get()); - - TestHostCookie(manager); -} - -// Test creation of a host cookie. -TEST(CookieTest, HostCookieOnDisk) { - ScopedTempDir temp_dir; - - // Create a new temporary directory. - EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); - - CefRefPtr manager = - CefCookieManager::CreateManager(temp_dir.path().value()); - EXPECT_TRUE(manager.get()); - - TestHostCookie(manager); -} - -// Test creation of multiple cookies. -TEST(CookieTest, MultipleCookiesGlobal) { - CefRefPtr manager = CefCookieManager::GetGlobalManager(); - EXPECT_TRUE(manager.get()); - - TestMultipleCookies(manager); -} - -// Test creation of multiple cookies. -TEST(CookieTest, MultipleCookiesInMemory) { - CefRefPtr manager = - CefCookieManager::CreateManager(CefString()); - EXPECT_TRUE(manager.get()); - - TestMultipleCookies(manager); -} - -// Test creation of multiple cookies. -TEST(CookieTest, MultipleCookiesOnDisk) { - ScopedTempDir temp_dir; - - // Create a new temporary directory. - EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); - - CefRefPtr manager = - CefCookieManager::CreateManager(temp_dir.path().value()); - EXPECT_TRUE(manager.get()); - - TestMultipleCookies(manager); -} - -TEST(CookieTest, AllCookiesGlobal) { - CefRefPtr manager = CefCookieManager::GetGlobalManager(); - EXPECT_TRUE(manager.get()); - - TestAllCookies(manager); -} - -TEST(CookieTest, AllCookiesInMemory) { - CefRefPtr manager = - CefCookieManager::CreateManager(CefString()); - EXPECT_TRUE(manager.get()); - - TestAllCookies(manager); -} - -TEST(CookieTest, AllCookiesOnDisk) { - ScopedTempDir temp_dir; - - // Create a new temporary directory. - EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); - - CefRefPtr manager = - CefCookieManager::CreateManager(temp_dir.path().value()); - EXPECT_TRUE(manager.get()); - - TestAllCookies(manager); -} - -TEST(CookieTest, ChangeDirectoryGlobal) { - CefRefPtr manager = CefCookieManager::GetGlobalManager(); - EXPECT_TRUE(manager.get()); - - std::string cache_path; - CefTestSuite::GetCachePath(cache_path); - - TestChangeDirectory(manager, cache_path); -} - -TEST(CookieTest, ChangeDirectoryCreated) { - CefRefPtr manager = - CefCookieManager::CreateManager(CefString()); - EXPECT_TRUE(manager.get()); - - TestChangeDirectory(manager, CefString()); -} - - -namespace { - -const char* kCookieJSUrl1 = "http://tests/cookie1.html"; -const char* kCookieJSUrl2 = "http://tests/cookie2.html"; - -class CookieTestJSHandler : public TestHandler { - public: - CookieTestJSHandler() {} - - virtual void RunTest() OVERRIDE { - // Create =new in-memory managers. - manager1_ = CefCookieManager::CreateManager(CefString()); - manager2_ = CefCookieManager::CreateManager(CefString()); - - std::string page = - "" - "" - "COOKIE TEST1"; - AddResource(kCookieJSUrl1, page, "text/html"); - - page = - "" - "" - "COOKIE TEST2"; - AddResource(kCookieJSUrl2, page, "text/html"); - - // Create the browser - CreateBrowser(kCookieJSUrl1); - } - - virtual void OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) OVERRIDE { - std::string url = frame->GetURL(); - if (url == kCookieJSUrl1) { - got_load_end1_.yes(); - VerifyCookie(manager1_, url, "name1", "value1", got_cookie1_); - - // Go to the next URL - frame->LoadURL(kCookieJSUrl2); - } else { - got_load_end2_.yes(); - VerifyCookie(manager2_, url, "name2", "value2", got_cookie2_); - - DestroyTest(); - } - } - - virtual CefRefPtr GetCookieManager( - CefRefPtr browser, - const CefString& main_url) OVERRIDE { - if (main_url == kCookieJSUrl1) { - // Return the first cookie manager. - got_cookie_manager1_.yes(); - return manager1_; - } else { - // Return the second cookie manager. - got_cookie_manager2_.yes(); - return manager2_; - } - } - - // Verify that the cookie was set successfully. - void VerifyCookie(CefRefPtr manager, - const std::string& url, - const std::string& name, - const std::string& value, - TrackCallback& callback) { - base::WaitableEvent event(false, false); - CookieVector cookies; - - // Get the cookie. - VisitUrlCookies(manager, url, false, cookies, false, event); - - if (cookies.size() == 1 && CefString(&cookies[0].name) == name && - CefString(&cookies[0].value) == value) { - callback.yes(); - } - } - - CefRefPtr manager1_; - CefRefPtr manager2_; - - TrackCallback got_cookie_manager1_; - TrackCallback got_cookie_manager2_; - TrackCallback got_load_end1_; - TrackCallback got_load_end2_; - TrackCallback got_cookie1_; - TrackCallback got_cookie2_; -}; - -} // namespace - -// Verify use of multiple cookie managers vis JS. -TEST(CookieTest, GetCookieManagerJS) { - CefRefPtr handler = new CookieTestJSHandler(); - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_cookie_manager1_); - EXPECT_TRUE(handler->got_cookie_manager2_); - EXPECT_TRUE(handler->got_load_end1_); - EXPECT_TRUE(handler->got_load_end2_); - EXPECT_TRUE(handler->got_cookie1_); - EXPECT_TRUE(handler->got_cookie2_); -} - - -namespace { - -class CookieTestSchemeHandler : public TestHandler { - public: - class SchemeHandler : public CefResourceHandler { - public: - explicit SchemeHandler(CookieTestSchemeHandler* handler) - : handler_(handler), - offset_(0) {} - - virtual bool ProcessRequest(CefRefPtr request, - CefRefPtr callback) - OVERRIDE { - std::string url = request->GetURL(); - if (url == handler_->url1_) { - content_ = "COOKIE TEST1"; - cookie_ = "name1=value1"; - handler_->got_process_request1_.yes(); - } else if (url == handler_->url2_) { - content_ = "COOKIE TEST2"; - cookie_ = "name2=value2"; - handler_->got_process_request2_.yes(); - } else if (url == handler_->url3_) { - content_ = "COOKIE TEST3"; - handler_->got_process_request3_.yes(); - - // Verify that the cookie was passed in. - CefRequest::HeaderMap headerMap; - request->GetHeaderMap(headerMap); - CefRequest::HeaderMap::iterator it = headerMap.find("Cookie"); - if (it != headerMap.end() && it->second == "name2=value2") - handler_->got_process_request_cookie_.yes(); - - } - callback->Continue(); - return true; - } - - virtual void GetResponseHeaders(CefRefPtr response, - int64& response_length, - CefString& redirectUrl) OVERRIDE { - response_length = content_.size(); - - response->SetStatus(200); - response->SetMimeType("text/html"); - - if (!cookie_.empty()) { - CefResponse::HeaderMap headerMap; - response->GetHeaderMap(headerMap); - headerMap.insert(std::make_pair("Set-Cookie", cookie_)); - response->SetHeaderMap(headerMap); - } - } - - virtual bool ReadResponse(void* data_out, - int bytes_to_read, - int& bytes_read, - CefRefPtr callback) - OVERRIDE { - bool has_data = false; - bytes_read = 0; - - size_t size = content_.size(); - if (offset_ < size) { - int transfer_size = - std::min(bytes_to_read, static_cast(size - offset_)); - memcpy(data_out, content_.c_str() + offset_, transfer_size); - offset_ += transfer_size; - - bytes_read = transfer_size; - has_data = true; - } - - return has_data; - } - - virtual void Cancel() OVERRIDE { - } - - private: - CookieTestSchemeHandler* handler_; - std::string content_; - size_t offset_; - std::string cookie_; - - IMPLEMENT_REFCOUNTING(SchemeHandler); - }; - - class SchemeHandlerFactory : public CefSchemeHandlerFactory { - public: - explicit SchemeHandlerFactory(CookieTestSchemeHandler* handler) - : handler_(handler) {} - - virtual CefRefPtr Create( - CefRefPtr browser, - CefRefPtr frame, - const CefString& scheme_name, - CefRefPtr request) OVERRIDE { - std::string url = request->GetURL(); - if (url == handler_->url3_) { - // Verify that the cookie was not passed in. - CefRequest::HeaderMap headerMap; - request->GetHeaderMap(headerMap); - CefRequest::HeaderMap::iterator it = headerMap.find("Cookie"); - if (it != headerMap.end() && it->second == "name2=value2") - handler_->got_create_cookie_.yes(); - } - - return new SchemeHandler(handler_); - } - - private: - CookieTestSchemeHandler* handler_; - - IMPLEMENT_REFCOUNTING(SchemeHandlerFactory); - }; - - CookieTestSchemeHandler(const std::string& scheme) : scheme_(scheme) { - url1_ = scheme + "://cookie-tests/cookie1.html"; - url2_ = scheme + "://cookie-tests/cookie2.html"; - url3_ = scheme + "://cookie-tests/cookie3.html"; - } - - virtual void RunTest() OVERRIDE { - // Create new in-memory managers. - manager1_ = CefCookieManager::CreateManager(CefString()); - manager2_ = CefCookieManager::CreateManager(CefString()); - - if (scheme_ != "http") { - std::vector schemes; - schemes.push_back("http"); - schemes.push_back("https"); - schemes.push_back(scheme_); - - manager1_->SetSupportedSchemes(schemes); - manager2_->SetSupportedSchemes(schemes); - } - - // Register the scheme handler. - CefRegisterSchemeHandlerFactory(scheme_, "cookie-tests", - new SchemeHandlerFactory(this)); - - // Create the browser - CreateBrowser(url1_); - } - - virtual void OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) OVERRIDE { - std::string url = frame->GetURL(); - if (url == url1_) { - got_load_end1_.yes(); - VerifyCookie(manager1_, url, "name1", "value1", got_cookie1_); - - // Go to the next URL - frame->LoadURL(url2_); - } else if (url == url2_) { - got_load_end2_.yes(); - VerifyCookie(manager2_, url, "name2", "value2", got_cookie2_); - - // Go to the next URL - frame->LoadURL(url3_); - } else { - got_load_end3_.yes(); - VerifyCookie(manager2_, url, "name2", "value2", got_cookie3_); - - // Unregister the scheme handler. - CefRegisterSchemeHandlerFactory(scheme_, "cookie-tests", NULL); - - DestroyTest(); - } - } - - virtual CefRefPtr GetCookieManager( - CefRefPtr browser, - const CefString& main_url) OVERRIDE { - if (main_url == url1_) { - // Return the first cookie manager. - got_cookie_manager1_.yes(); - return manager1_; - } else { - // Return the second cookie manager. - got_cookie_manager2_.yes(); - return manager2_; - } - } - - // Verify that the cookie was set successfully. - void VerifyCookie(CefRefPtr manager, - const std::string& url, - const std::string& name, - const std::string& value, - TrackCallback& callback) { - base::WaitableEvent event(false, false); - CookieVector cookies; - - // Get the cookie. - VisitUrlCookies(manager, url, false, cookies, false, event); - - if (cookies.size() == 1 && CefString(&cookies[0].name) == name && - CefString(&cookies[0].value) == value) { - callback.yes(); - } - } - - std::string scheme_; - std::string url1_; - std::string url2_; - std::string url3_; - - CefRefPtr manager1_; - CefRefPtr manager2_; - - TrackCallback got_process_request1_; - TrackCallback got_process_request2_; - TrackCallback got_process_request3_; - TrackCallback got_create_cookie_; - TrackCallback got_process_request_cookie_; - TrackCallback got_cookie_manager1_; - TrackCallback got_cookie_manager2_; - TrackCallback got_load_end1_; - TrackCallback got_load_end2_; - TrackCallback got_load_end3_; - TrackCallback got_cookie1_; - TrackCallback got_cookie2_; - TrackCallback got_cookie3_; -}; - -} // namespace - -// Verify use of multiple cookie managers via HTTP. -TEST(CookieTest, GetCookieManagerHttp) { - CefRefPtr handler = - new CookieTestSchemeHandler("http"); - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_process_request1_); - EXPECT_TRUE(handler->got_process_request2_); - EXPECT_TRUE(handler->got_process_request3_); - EXPECT_FALSE(handler->got_create_cookie_); - EXPECT_TRUE(handler->got_process_request_cookie_); - EXPECT_TRUE(handler->got_cookie_manager1_); - EXPECT_TRUE(handler->got_cookie_manager2_); - EXPECT_TRUE(handler->got_load_end1_); - EXPECT_TRUE(handler->got_load_end2_); - EXPECT_TRUE(handler->got_load_end3_); - EXPECT_TRUE(handler->got_cookie1_); - EXPECT_TRUE(handler->got_cookie2_); - EXPECT_TRUE(handler->got_cookie3_); -} - -// Verify use of multiple cookie managers via a custom scheme. -TEST(CookieTest, GetCookieManagerCustom) { - CefRefPtr handler = - new CookieTestSchemeHandler("ccustom"); - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_process_request1_); - EXPECT_TRUE(handler->got_process_request2_); - EXPECT_TRUE(handler->got_process_request3_); - EXPECT_FALSE(handler->got_create_cookie_); - EXPECT_TRUE(handler->got_process_request_cookie_); - EXPECT_TRUE(handler->got_cookie_manager1_); - EXPECT_TRUE(handler->got_cookie_manager2_); - EXPECT_TRUE(handler->got_load_end1_); - EXPECT_TRUE(handler->got_load_end2_); - EXPECT_TRUE(handler->got_load_end3_); - EXPECT_TRUE(handler->got_cookie1_); - EXPECT_TRUE(handler->got_cookie2_); - EXPECT_TRUE(handler->got_cookie3_); -} - -// Entry point for registering custom schemes. -// Called from client_app_delegates.cc. -void RegisterCookieCustomSchemes( - CefRefPtr registrar, - std::vector& cookiable_schemes) { - // Used by GetCookieManagerCustom test. - registrar->AddCustomScheme("ccustom", true, false, false); -} diff --git a/tests/unittests/dom_unittest.cc b/tests/unittests/dom_unittest.cc deleted file mode 100644 index 26ba0d453..000000000 --- a/tests/unittests/dom_unittest.cc +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "include/cef_dom.h" -#include "tests/cefclient/client_app.h" -#include "tests/unittests/test_handler.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -const char* kTestUrl = "http://tests/DOMTest.Test"; -const char* kTestMessage = "DOMTest.Message"; - -enum DOMTestType { - DOM_TEST_STRUCTURE, - DOM_TEST_MODIFY, -}; - -class TestDOMVisitor : public CefDOMVisitor { - public: - explicit TestDOMVisitor(CefRefPtr browser, DOMTestType test_type) - : browser_(browser), - test_type_(test_type) { - } - - void TestHeadNodeStructure(CefRefPtr headNode) { - EXPECT_TRUE(headNode.get()); - EXPECT_TRUE(headNode->IsElement()); - EXPECT_FALSE(headNode->IsText()); - EXPECT_EQ(headNode->GetName(), "HEAD"); - EXPECT_EQ(headNode->GetElementTagName(), "HEAD"); - - EXPECT_TRUE(headNode->HasChildren()); - EXPECT_FALSE(headNode->HasElementAttributes()); - - CefRefPtr titleNode = headNode->GetFirstChild(); - EXPECT_TRUE(titleNode.get()); - EXPECT_TRUE(titleNode->IsElement()); - EXPECT_FALSE(titleNode->IsText()); - EXPECT_EQ(titleNode->GetName(), "TITLE"); - EXPECT_EQ(titleNode->GetElementTagName(), "TITLE"); - EXPECT_TRUE(titleNode->GetParent()->IsSame(headNode)); - - EXPECT_FALSE(titleNode->GetNextSibling().get()); - EXPECT_FALSE(titleNode->GetPreviousSibling().get()); - EXPECT_TRUE(titleNode->HasChildren()); - EXPECT_FALSE(titleNode->HasElementAttributes()); - - CefRefPtr textNode = titleNode->GetFirstChild(); - EXPECT_TRUE(textNode.get()); - EXPECT_FALSE(textNode->IsElement()); - EXPECT_TRUE(textNode->IsText()); - EXPECT_EQ(textNode->GetValue(), "The Title"); - EXPECT_TRUE(textNode->GetParent()->IsSame(titleNode)); - - EXPECT_FALSE(textNode->GetNextSibling().get()); - EXPECT_FALSE(textNode->GetPreviousSibling().get()); - EXPECT_FALSE(textNode->HasChildren()); - } - - void TestBodyNodeStructure(CefRefPtr bodyNode) { - EXPECT_TRUE(bodyNode.get()); - EXPECT_TRUE(bodyNode->IsElement()); - EXPECT_FALSE(bodyNode->IsText()); - EXPECT_EQ(bodyNode->GetName(), "BODY"); - EXPECT_EQ(bodyNode->GetElementTagName(), "BODY"); - - EXPECT_TRUE(bodyNode->HasChildren()); - EXPECT_FALSE(bodyNode->HasElementAttributes()); - - CefRefPtr h1Node = bodyNode->GetFirstChild(); - EXPECT_TRUE(h1Node.get()); - EXPECT_TRUE(h1Node->IsElement()); - EXPECT_FALSE(h1Node->IsText()); - EXPECT_EQ(h1Node->GetName(), "H1"); - EXPECT_EQ(h1Node->GetElementTagName(), "H1"); - - EXPECT_FALSE(h1Node->GetNextSibling().get()); - EXPECT_FALSE(h1Node->GetPreviousSibling().get()); - EXPECT_TRUE(h1Node->HasChildren()); - EXPECT_FALSE(h1Node->HasElementAttributes()); - - CefRefPtr textNode = h1Node->GetFirstChild(); - EXPECT_TRUE(textNode.get()); - EXPECT_FALSE(textNode->IsElement()); - EXPECT_TRUE(textNode->IsText()); - EXPECT_EQ(textNode->GetValue(), "Hello From"); - - EXPECT_FALSE(textNode->GetPreviousSibling().get()); - EXPECT_FALSE(textNode->HasChildren()); - - CefRefPtr brNode = textNode->GetNextSibling(); - EXPECT_TRUE(brNode.get()); - EXPECT_TRUE(brNode->IsElement()); - EXPECT_FALSE(brNode->IsText()); - EXPECT_EQ(brNode->GetName(), "BR"); - EXPECT_EQ(brNode->GetElementTagName(), "BR"); - - EXPECT_FALSE(brNode->HasChildren()); - - EXPECT_TRUE(brNode->HasElementAttributes()); - EXPECT_TRUE(brNode->HasElementAttribute("class")); - EXPECT_EQ(brNode->GetElementAttribute("class"), "some_class"); - EXPECT_TRUE(brNode->HasElementAttribute("id")); - EXPECT_EQ(brNode->GetElementAttribute("id"), "some_id"); - EXPECT_FALSE(brNode->HasElementAttribute("no_existing")); - - CefDOMNode::AttributeMap map; - brNode->GetElementAttributes(map); - ASSERT_EQ(map.size(), (size_t)2); - EXPECT_EQ(map["class"], "some_class"); - EXPECT_EQ(map["id"], "some_id"); - - // Can also retrieve by ID. - brNode = bodyNode->GetDocument()->GetElementById("some_id"); - EXPECT_TRUE(brNode.get()); - EXPECT_TRUE(brNode->IsElement()); - EXPECT_FALSE(brNode->IsText()); - EXPECT_EQ(brNode->GetName(), "BR"); - EXPECT_EQ(brNode->GetElementTagName(), "BR"); - - textNode = brNode->GetNextSibling(); - EXPECT_TRUE(textNode.get()); - EXPECT_FALSE(textNode->IsElement()); - EXPECT_TRUE(textNode->IsText()); - EXPECT_EQ(textNode->GetValue(), "Main Frame"); - - EXPECT_FALSE(textNode->GetNextSibling().get()); - EXPECT_FALSE(textNode->HasChildren()); - } - - // Test document structure by iterating through the DOM tree. - void TestStructure(CefRefPtr document) { - EXPECT_EQ(document->GetTitle(), "The Title"); - EXPECT_EQ(document->GetBaseURL(), kTestUrl); - EXPECT_EQ(document->GetCompleteURL("foo.html"), "http://tests/foo.html"); - - // Navigate the complete document structure. - CefRefPtr docNode = document->GetDocument(); - EXPECT_TRUE(docNode.get()); - EXPECT_FALSE(docNode->IsElement()); - EXPECT_FALSE(docNode->IsText()); - - CefRefPtr htmlNode = docNode->GetFirstChild(); - EXPECT_TRUE(htmlNode.get()); - EXPECT_TRUE(htmlNode->IsElement()); - EXPECT_FALSE(htmlNode->IsText()); - EXPECT_EQ(htmlNode->GetName(), "HTML"); - EXPECT_EQ(htmlNode->GetElementTagName(), "HTML"); - - EXPECT_TRUE(htmlNode->HasChildren()); - EXPECT_FALSE(htmlNode->HasElementAttributes()); - - CefRefPtr headNode = htmlNode->GetFirstChild(); - TestHeadNodeStructure(headNode); - - CefRefPtr bodyNode = headNode->GetNextSibling(); - TestBodyNodeStructure(bodyNode); - - // Retrieve the head node directly. - headNode = document->GetHead(); - TestHeadNodeStructure(headNode); - - // Retrieve the body node directly. - bodyNode = document->GetBody(); - TestBodyNodeStructure(bodyNode); - } - - // Test document modification by changing the H1 tag. - void TestModify(CefRefPtr document) { - CefRefPtr bodyNode = document->GetBody(); - CefRefPtr h1Node = bodyNode->GetFirstChild(); - - ASSERT_EQ(h1Node->GetAsMarkup(), - "

Hello From
" - "Main Frame

"); - - CefRefPtr textNode = h1Node->GetFirstChild(); - ASSERT_EQ(textNode->GetValue(), "Hello From"); - ASSERT_TRUE(textNode->SetValue("A Different Message From")); - ASSERT_EQ(textNode->GetValue(), "A Different Message From"); - - CefRefPtr brNode = textNode->GetNextSibling(); - EXPECT_EQ(brNode->GetElementAttribute("class"), "some_class"); - EXPECT_TRUE(brNode->SetElementAttribute("class", "a_different_class")); - EXPECT_EQ(brNode->GetElementAttribute("class"), "a_different_class"); - - ASSERT_EQ(h1Node->GetAsMarkup(), - "

A Different Message From
Main Frame

"); - - ASSERT_FALSE(h1Node->SetValue("Something Different")); - } - - virtual void Visit(CefRefPtr document) OVERRIDE { - if (test_type_ == DOM_TEST_STRUCTURE) - TestStructure(document); - else if (test_type_ == DOM_TEST_MODIFY) - TestModify(document); - - DestroyTest(); - } - - protected: - // Return from the test. - void DestroyTest() { - // Check if the test has failed. - bool result = !TestFailed(); - - // Return the result to the browser process. - CefRefPtr return_msg = - CefProcessMessage::Create(kTestMessage); - EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result)); - EXPECT_TRUE(browser_->SendProcessMessage(PID_BROWSER, return_msg)); - } - - CefRefPtr browser_; - DOMTestType test_type_; - - IMPLEMENT_REFCOUNTING(TestDOMVisitor); -}; - -// Used in the render process. -class DOMRendererTest : public ClientApp::RenderDelegate { - public: - DOMRendererTest() { - } - - virtual bool OnProcessMessageReceived( - CefRefPtr app, - CefRefPtr browser, - CefProcessId source_process, - CefRefPtr message) OVERRIDE { - if (message->GetName() == kTestMessage) { - EXPECT_EQ(message->GetArgumentList()->GetSize(), (size_t)1); - int test_type = message->GetArgumentList()->GetInt(0); - - browser->GetMainFrame()->VisitDOM( - new TestDOMVisitor(browser, static_cast(test_type))); - return true; - } - return false; - } - - private: - IMPLEMENT_REFCOUNTING(DOMRendererTest); -}; - -// Used in the browser process. -class TestDOMHandler : public TestHandler { - public: - explicit TestDOMHandler(DOMTestType test) - : test_type_(test) { - } - - virtual void RunTest() OVERRIDE { - std::stringstream mainHtml; - mainHtml << - "" - "The Title" - "" - "

Hello From
" - "Main Frame

" - "" - ""; - - AddResource(kTestUrl, mainHtml.str(), "text/html"); - CreateBrowser(kTestUrl); - } - - virtual void OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) OVERRIDE { - if (frame->IsMain()) { - // Start the test in the render process. - CefRefPtr message( - CefProcessMessage::Create(kTestMessage)); - message->GetArgumentList()->SetInt(0, test_type_); - EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, message)); - } - } - - virtual bool OnProcessMessageReceived( - CefRefPtr browser, - CefProcessId source_process, - CefRefPtr message) OVERRIDE { - EXPECT_STREQ(message->GetName().ToString().c_str(), kTestMessage); - - got_message_.yes(); - - if (message->GetArgumentList()->GetBool(0)) - got_success_.yes(); - - // Test is complete. - DestroyTest(); - - return true; - } - - DOMTestType test_type_; - TrackCallback got_message_; - TrackCallback got_success_; -}; - -} // namespace - -// Test DOM structure reading. -TEST(DOMTest, Read) { - CefRefPtr handler = - new TestDOMHandler(DOM_TEST_STRUCTURE); - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_message_); - EXPECT_TRUE(handler->got_success_); -} - -// Test DOM modifications. -TEST(DOMTest, Modify) { - CefRefPtr handler = - new TestDOMHandler(DOM_TEST_MODIFY); - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_message_); - EXPECT_TRUE(handler->got_success_); -} - -// Entry point for creating DOM renderer test objects. -// Called from client_app_delegates.cc. -void CreateDOMRendererTests(ClientApp::RenderDelegateSet& delegates) { - delegates.insert(new DOMRendererTest); -} diff --git a/tests/unittests/jsdialog_unittest.cc b/tests/unittests/jsdialog_unittest.cc deleted file mode 100644 index df5312152..000000000 --- a/tests/unittests/jsdialog_unittest.cc +++ /dev/null @@ -1,413 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "include/cef_runnable.h" -#include "tests/unittests/test_handler.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -const char* kStartUrl = "http://tests/JSDialogTestHandler.Start"; -const char* kEndUrl = "http://tests/JSDialogTestHandler.End?r="; - -class JSDialogTestHandler : public TestHandler { - public: - enum TestType { - TYPE_ALERT, - TYPE_CONFIRM, - TYPE_PROMPT, - TYPE_ONBEFOREUNLOAD, - }; - enum TestMode { - MODE_SUPPRESS, - MODE_RUN_IMMEDIATE, - MODE_RUN_DELAYED, - }; - - JSDialogTestHandler(TestType type, - TestMode mode, - bool success, - const std::string& user_input, - const std::string& result) - : type_(type), - mode_(mode), - success_(success), - user_input_(user_input), - result_(result) { - } - - virtual void RunTest() OVERRIDE { - std::string content = "START"; - - AddResource(kStartUrl, content, "text/html"); - AddResource(kEndUrl, "END", "text/html"); - - // Create the browser - CreateBrowser(kStartUrl); - } - - virtual void OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) OVERRIDE { - if (!frame->IsMain()) - return; - - std::string url = frame->GetURL(); - if (url.find(kEndUrl) == 0) { - got_onloadend_.yes(); - - std::string result = url.substr(strlen(kEndUrl)); - EXPECT_STREQ(result_.c_str(), result.c_str()); - - DestroyTest(); - } else if (type_ == TYPE_ONBEFOREUNLOAD) { - // Trigger the onunload handler. - frame->LoadURL(kEndUrl); - } - } - - virtual void Continue(CefRefPtr callback) { - callback->Continue(success_, user_input_); - } - - virtual bool OnJSDialog(CefRefPtr browser, - const CefString& origin_url, - const CefString& accept_lang, - JSDialogType dialog_type, - const CefString& message_text, - const CefString& default_prompt_text, - CefRefPtr callback, - bool& suppress_message) OVERRIDE { - got_onjsdialog_.yes(); - - EXPECT_STREQ("http://tests/", origin_url.ToString().c_str()); - EXPECT_TRUE(accept_lang.empty()); - - if (type_ == TYPE_ALERT) { - EXPECT_EQ(JSDIALOGTYPE_ALERT, dialog_type); - EXPECT_STREQ("My alert message", message_text.ToString().c_str()); - EXPECT_TRUE(default_prompt_text.empty()); - } else if (type_ == TYPE_CONFIRM) { - EXPECT_EQ(JSDIALOGTYPE_CONFIRM, dialog_type); - EXPECT_STREQ("My confirm message", message_text.ToString().c_str()); - EXPECT_TRUE(default_prompt_text.empty()); - } else if (type_ == TYPE_PROMPT) { - EXPECT_EQ(JSDIALOGTYPE_PROMPT, dialog_type); - EXPECT_STREQ("My prompt message", message_text.ToString().c_str()); - EXPECT_STREQ("my default", default_prompt_text.ToString().c_str()); - } - - EXPECT_FALSE(suppress_message); - - if (mode_ == MODE_SUPPRESS) { - // Suppress the dialog. - suppress_message = true; - return false; - } else if (mode_ == MODE_RUN_IMMEDIATE) { - // Continue immediately. - callback->Continue(success_, user_input_); - } else if (mode_ == MODE_RUN_DELAYED) { - // Continue asynchronously. - CefPostTask(TID_UI, - NewCefRunnableMethod(this, &JSDialogTestHandler::Continue, callback)); - } - - return true; - } - - virtual bool OnBeforeUnloadDialog(CefRefPtr browser, - const CefString& message_text, - bool is_reload, - CefRefPtr callback) - OVERRIDE { - got_onbeforeunloaddialog_.yes(); - - if (type_ == TYPE_ONBEFOREUNLOAD) { - EXPECT_STREQ("My unload message", message_text.ToString().c_str()); - EXPECT_FALSE(is_reload); - } - - if (mode_ == MODE_RUN_IMMEDIATE) { - // Continue immediately. - callback->Continue(success_, user_input_); - } else if (mode_ == MODE_RUN_DELAYED) { - // Continue asynchronously. - CefPostTask(TID_UI, - NewCefRunnableMethod(this, &JSDialogTestHandler::Continue, callback)); - } - - return true; - } - - virtual void OnResetDialogState(CefRefPtr browser) OVERRIDE { - got_onresetdialogstate_.yes(); - } - - TestType type_; - TestMode mode_; - bool success_; - std::string user_input_; - std::string result_; - - TrackCallback got_onjsdialog_; - TrackCallback got_onbeforeunloaddialog_; - TrackCallback got_onresetdialogstate_; - TrackCallback got_onloadend_; -}; - -} // namespace - -// Alert dialog with suppression. -TEST(JSDialogTest, AlertSuppress) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_ALERT, - JSDialogTestHandler::MODE_SUPPRESS, - true, // success - "", // user_input - ""); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Alert dialog with immediate callback. -TEST(JSDialogTest, AlertRunImmediate) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_ALERT, - JSDialogTestHandler::MODE_RUN_IMMEDIATE, - true, // success - "", // user_input - ""); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Alert dialog with delayed callback. -TEST(JSDialogTest, AlertRunDelayed) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_ALERT, - JSDialogTestHandler::MODE_RUN_DELAYED, - true, // success - "", // user_input - ""); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Confirm dialog with suppression. -TEST(JSDialogTest, ConfirmSuppress) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, - JSDialogTestHandler::MODE_SUPPRESS, - true, // success - "", // user_input - "cancel"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Confirm dialog run immediately return OK. -TEST(JSDialogTest, ConfirmRunImmediateOk) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, - JSDialogTestHandler::MODE_RUN_IMMEDIATE, - true, // success - "", // user_input - "ok"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Confirm dialog run immediately return Cancel. -TEST(JSDialogTest, ConfirmRunImmediateCancel) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, - JSDialogTestHandler::MODE_RUN_IMMEDIATE, - false, // success - "", // user_input - "cancel"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Confirm dialog run delayed return OK. -TEST(JSDialogTest, ConfirmRunDelayedOk) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, - JSDialogTestHandler::MODE_RUN_DELAYED, - true, // success - "", // user_input - "ok"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Confirm dialog run delayed return Cancel. -TEST(JSDialogTest, ConfirmRunDelayedCancel) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_CONFIRM, - JSDialogTestHandler::MODE_RUN_DELAYED, - false, // success - "", // user_input - "cancel"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Prompt dialog with suppression. -TEST(JSDialogTest, PromptSuppress) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, - JSDialogTestHandler::MODE_SUPPRESS, - true, // success - "some_value", // user_input - "null"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Prompt dialog run immediately return OK. -TEST(JSDialogTest, PromptRunImmediateOk) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, - JSDialogTestHandler::MODE_RUN_IMMEDIATE, - true, // success - "some_value", // user_input - "some_value"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Prompt dialog run immediately return Cancel. -TEST(JSDialogTest, PromptRunImmediateCancel) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, - JSDialogTestHandler::MODE_RUN_IMMEDIATE, - false, // success - "some_value", // user_input - "null"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Prompt dialog run delayed return OK. -TEST(JSDialogTest, PromptRunDelayedOk) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, - JSDialogTestHandler::MODE_RUN_DELAYED, - true, // success - "some_value", // user_input - "some_value"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// Prompt dialog run delayed return Cancel. -TEST(JSDialogTest, PromptRunDelayedCancel) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_PROMPT, - JSDialogTestHandler::MODE_RUN_DELAYED, - false, // success - "some_value", // user_input - "null"); // result - handler->ExecuteTest(); - - EXPECT_TRUE(handler->got_onjsdialog_); - EXPECT_FALSE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// OnBeforeUnload dialog with immediate callback. -TEST(JSDialogTest, OnBeforeUnloadRunImmediate) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_ONBEFOREUNLOAD, - JSDialogTestHandler::MODE_RUN_IMMEDIATE, - true, // success - "", // user_input - ""); // result - handler->ExecuteTest(); - - EXPECT_FALSE(handler->got_onjsdialog_); - EXPECT_TRUE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} - -// OnBeforeUnload dialog with delayed callback. -TEST(JSDialogTest, OnBeforeUnloadRunDelayed) { - CefRefPtr handler = - new JSDialogTestHandler(JSDialogTestHandler::TYPE_ONBEFOREUNLOAD, - JSDialogTestHandler::MODE_RUN_DELAYED, - true, // success - "", // user_input - ""); // result - handler->ExecuteTest(); - - EXPECT_FALSE(handler->got_onjsdialog_); - EXPECT_TRUE(handler->got_onbeforeunloaddialog_); - EXPECT_TRUE(handler->got_onresetdialogstate_); - EXPECT_TRUE(handler->got_onloadend_); -} diff --git a/tests/unittests/mac/English.lproj/InfoPlist.strings b/tests/unittests/mac/English.lproj/InfoPlist.strings deleted file mode 100644 index fe2abe11b..000000000 --- a/tests/unittests/mac/English.lproj/InfoPlist.strings +++ /dev/null @@ -1,3 +0,0 @@ -/* Localized versions of Info.plist keys */ - -NSHumanReadableCopyright = "© Chromium Embedded Framework Authors, 2010"; diff --git a/tests/unittests/mac/English.lproj/MainMenu.xib b/tests/unittests/mac/English.lproj/MainMenu.xib deleted file mode 100644 index e4f7c1fc3..000000000 --- a/tests/unittests/mac/English.lproj/MainMenu.xib +++ /dev/null @@ -1,2880 +0,0 @@ - - - - 1050 - 10F569 - 820 - 1038.29 - 461.00 - - com.apple.InterfaceBuilder.CocoaPlugin - 820 - - - YES - - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - - - PluginDependencyRecalculationVersion - - - - YES - - NSApplication - - - FirstResponder - - - NSApplication - - - AMainMenu - - YES - - - cefclient - - 1048576 - 2147483647 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - - submenuAction: - - TestShell - - YES - - - About cefclient - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Preferences… - , - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Services - - 1048576 - 2147483647 - - - submenuAction: - - Services - - YES - - _NSServicesMenu - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Hide cefclient - h - 1048576 - 2147483647 - - - - - - Hide Others - h - 1572864 - 2147483647 - - - - - - Show All - - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Quit cefclient - q - 1048576 - 2147483647 - - - - - _NSAppleMenu - - - - - File - - 1048576 - 2147483647 - - - submenuAction: - - File - - YES - - - New - n - 1048576 - 2147483647 - - - - - - Open… - o - 1048576 - 2147483647 - - - - - - Open Recent - - 1048576 - 2147483647 - - - submenuAction: - - Open Recent - - YES - - - Clear Menu - - 1048576 - 2147483647 - - - - - _NSRecentDocumentsMenu - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Close - w - 1048576 - 2147483647 - - - - - - Save - s - 1048576 - 2147483647 - - - - - - Save As… - S - 1179648 - 2147483647 - - - - - - Revert to Saved - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Page Setup... - P - 1179648 - 2147483647 - - - - - - - Print… - p - 1048576 - 2147483647 - - - - - - - - - Edit - - 1048576 - 2147483647 - - - submenuAction: - - Edit - - YES - - - Undo - z - 1048576 - 2147483647 - - - - - - Redo - Z - 1179648 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Cut - x - 1048576 - 2147483647 - - - - - - Copy - c - 1048576 - 2147483647 - - - - - - Paste - v - 1048576 - 2147483647 - - - - - - Delete - - 1048576 - 2147483647 - - - - - - Select All - a - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Find - - 1048576 - 2147483647 - - - submenuAction: - - Find - - YES - - - Find… - f - 1048576 - 2147483647 - - - 1 - - - - Find Next - g - 1048576 - 2147483647 - - - 2 - - - - Find Previous - G - 1179648 - 2147483647 - - - 3 - - - - Use Selection for Find - e - 1048576 - 2147483647 - - - 7 - - - - Jump to Selection - j - 1048576 - 2147483647 - - - - - - - - - Spelling and Grammar - - 1048576 - 2147483647 - - - submenuAction: - - Spelling and Grammar - - YES - - - Show Spelling… - : - 1048576 - 2147483647 - - - - - - Check Spelling - ; - 1048576 - 2147483647 - - - - - - Check Spelling While Typing - - 1048576 - 2147483647 - - - - - - Check Grammar With Spelling - - 1048576 - 2147483647 - - - - - - - - - Substitutions - - 1048576 - 2147483647 - - - submenuAction: - - Substitutions - - YES - - - Smart Copy/Paste - f - 1048576 - 2147483647 - - - 1 - - - - Smart Quotes - g - 1048576 - 2147483647 - - - 2 - - - - Smart Links - G - 1179648 - 2147483647 - - - 3 - - - - - - - Speech - - 1048576 - 2147483647 - - - submenuAction: - - Speech - - YES - - - Start Speaking - - 1048576 - 2147483647 - - - - - - Stop Speaking - - 1048576 - 2147483647 - - - - - - - - - - - - Format - - 1048576 - 2147483647 - - - submenuAction: - - Format - - YES - - - Show Fonts - t - 1048576 - 2147483647 - - - - - - Show Colors - C - 1179648 - 2147483647 - - - - - - - - - View - - 1048576 - 2147483647 - - - submenuAction: - - View - - YES - - - Show Toolbar - t - 1572864 - 2147483647 - - - - - - Customize Toolbar… - - 1048576 - 2147483647 - - - - - - - - - Window - - 1048576 - 2147483647 - - - submenuAction: - - Window - - YES - - - Minimize - m - 1048576 - 2147483647 - - - - - - Zoom - - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Bring All to Front - - 1048576 - 2147483647 - - - - - _NSWindowsMenu - - - - - Help - - 1048576 - 2147483647 - - - submenuAction: - - Help - - YES - - - cefclient Help - ? - 1048576 - 2147483647 - - - - - - - - _NSMainMenu - - - YES - - - - - YES - - - performMiniaturize: - - - - 37 - - - - arrangeInFront: - - - - 39 - - - - print: - - - - 86 - - - - runPageLayout: - - - - 87 - - - - clearRecentDocuments: - - - - 127 - - - - orderFrontStandardAboutPanel: - - - - 142 - - - - performClose: - - - - 193 - - - - toggleContinuousSpellChecking: - - - - 222 - - - - undo: - - - - 223 - - - - copy: - - - - 224 - - - - checkSpelling: - - - - 225 - - - - paste: - - - - 226 - - - - stopSpeaking: - - - - 227 - - - - cut: - - - - 228 - - - - showGuessPanel: - - - - 230 - - - - redo: - - - - 231 - - - - selectAll: - - - - 232 - - - - startSpeaking: - - - - 233 - - - - delete: - - - - 235 - - - - performZoom: - - - - 240 - - - - performFindPanelAction: - - - - 241 - - - - centerSelectionInVisibleArea: - - - - 245 - - - - toggleGrammarChecking: - - - - 347 - - - - toggleSmartInsertDelete: - - - - 355 - - - - toggleAutomaticQuoteSubstitution: - - - - 356 - - - - toggleAutomaticLinkDetection: - - - - 357 - - - - showHelp: - - - - 360 - - - - orderFrontColorPanel: - - - - 361 - - - - saveDocument: - - - - 362 - - - - saveDocumentAs: - - - - 363 - - - - revertDocumentToSaved: - - - - 364 - - - - runToolbarCustomizationPalette: - - - - 365 - - - - toggleToolbarShown: - - - - 366 - - - - hide: - - - - 367 - - - - hideOtherApplications: - - - - 368 - - - - terminate: - - - - 369 - - - - unhideAllApplications: - - - - 370 - - - - newDocument: - - - - 373 - - - - openDocument: - - - - 374 - - - - - YES - - 0 - - YES - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 29 - - - YES - - - - - - - - - - MainMenu - - - 19 - - - YES - - - - - - 56 - - - YES - - - - - - 103 - - - YES - - - - 1 - - - 217 - - - YES - - - - - - 83 - - - YES - - - - - - 81 - - - YES - - - - - - - - - - - - - - - - 75 - - - 3 - - - 80 - - - 8 - - - 78 - - - 6 - - - 72 - - - - - 82 - - - 9 - - - 124 - - - YES - - - - - - 77 - - - 5 - - - 73 - - - 1 - - - 79 - - - 7 - - - 112 - - - 10 - - - 74 - - - 2 - - - 125 - - - YES - - - - - - 126 - - - - - 205 - - - YES - - - - - - - - - - - - - - - - - - 202 - - - - - 198 - - - - - 207 - - - - - 214 - - - - - 199 - - - - - 203 - - - - - 197 - - - - - 206 - - - - - 215 - - - - - 218 - - - YES - - - - - - 216 - - - YES - - - - - - 200 - - - YES - - - - - - - - - 219 - - - - - 201 - - - - - 204 - - - - - 220 - - - YES - - - - - - - - - - 213 - - - - - 210 - - - - - 221 - - - - - 208 - - - - - 209 - - - - - 106 - - - YES - - - - 2 - - - 111 - - - - - 57 - - - YES - - - - - - - - - - - - - - - - 58 - - - - - 134 - - - - - 150 - - - - - 136 - - - 1111 - - - 144 - - - - - 129 - - - 121 - - - 143 - - - - - 236 - - - - - 131 - - - YES - - - - - - 149 - - - - - 145 - - - - - 130 - - - - - 24 - - - YES - - - - - - - - - 92 - - - - - 5 - - - - - 239 - - - - - 23 - - - - - 295 - - - YES - - - - - - 296 - - - YES - - - - - - - 297 - - - - - 298 - - - - - 299 - - - YES - - - - - - 300 - - - YES - - - - - - - 344 - - - - - 345 - - - - - 211 - - - YES - - - - - - 212 - - - YES - - - - - - - 195 - - - - - 196 - - - - - 346 - - - - - 348 - - - YES - - - - - - 349 - - - YES - - - - - - - - 350 - - - - - 351 - - - - - 354 - - - - - 389 - - - - - - - YES - - YES - -3.IBPluginDependency - 103.IBPluginDependency - 103.ImportedFromIB2 - 106.IBEditorWindowLastContentRect - 106.IBPluginDependency - 106.ImportedFromIB2 - 106.editorWindowContentRectSynchronizationRect - 111.IBPluginDependency - 111.ImportedFromIB2 - 112.IBPluginDependency - 112.ImportedFromIB2 - 124.IBPluginDependency - 124.ImportedFromIB2 - 125.IBPluginDependency - 125.ImportedFromIB2 - 125.editorWindowContentRectSynchronizationRect - 126.IBPluginDependency - 126.ImportedFromIB2 - 129.IBPluginDependency - 129.ImportedFromIB2 - 130.IBPluginDependency - 130.ImportedFromIB2 - 130.editorWindowContentRectSynchronizationRect - 131.IBPluginDependency - 131.ImportedFromIB2 - 134.IBPluginDependency - 134.ImportedFromIB2 - 136.IBPluginDependency - 136.ImportedFromIB2 - 143.IBPluginDependency - 143.ImportedFromIB2 - 144.IBPluginDependency - 144.ImportedFromIB2 - 145.IBPluginDependency - 145.ImportedFromIB2 - 149.IBPluginDependency - 149.ImportedFromIB2 - 150.IBPluginDependency - 150.ImportedFromIB2 - 19.IBPluginDependency - 19.ImportedFromIB2 - 195.IBPluginDependency - 195.ImportedFromIB2 - 196.IBPluginDependency - 196.ImportedFromIB2 - 197.IBPluginDependency - 197.ImportedFromIB2 - 198.IBPluginDependency - 198.ImportedFromIB2 - 199.IBPluginDependency - 199.ImportedFromIB2 - 200.IBEditorWindowLastContentRect - 200.IBPluginDependency - 200.ImportedFromIB2 - 200.editorWindowContentRectSynchronizationRect - 201.IBPluginDependency - 201.ImportedFromIB2 - 202.IBPluginDependency - 202.ImportedFromIB2 - 203.IBPluginDependency - 203.ImportedFromIB2 - 204.IBPluginDependency - 204.ImportedFromIB2 - 205.IBEditorWindowLastContentRect - 205.IBPluginDependency - 205.ImportedFromIB2 - 205.editorWindowContentRectSynchronizationRect - 206.IBPluginDependency - 206.ImportedFromIB2 - 207.IBPluginDependency - 207.ImportedFromIB2 - 208.IBPluginDependency - 208.ImportedFromIB2 - 209.IBPluginDependency - 209.ImportedFromIB2 - 210.IBPluginDependency - 210.ImportedFromIB2 - 211.IBPluginDependency - 211.ImportedFromIB2 - 212.IBEditorWindowLastContentRect - 212.IBPluginDependency - 212.ImportedFromIB2 - 212.editorWindowContentRectSynchronizationRect - 213.IBPluginDependency - 213.ImportedFromIB2 - 214.IBPluginDependency - 214.ImportedFromIB2 - 215.IBPluginDependency - 215.ImportedFromIB2 - 216.IBPluginDependency - 216.ImportedFromIB2 - 217.IBPluginDependency - 217.ImportedFromIB2 - 218.IBPluginDependency - 218.ImportedFromIB2 - 219.IBPluginDependency - 219.ImportedFromIB2 - 220.IBEditorWindowLastContentRect - 220.IBPluginDependency - 220.ImportedFromIB2 - 220.editorWindowContentRectSynchronizationRect - 221.IBPluginDependency - 221.ImportedFromIB2 - 23.IBPluginDependency - 23.ImportedFromIB2 - 236.IBPluginDependency - 236.ImportedFromIB2 - 239.IBPluginDependency - 239.ImportedFromIB2 - 24.IBEditorWindowLastContentRect - 24.IBPluginDependency - 24.ImportedFromIB2 - 24.editorWindowContentRectSynchronizationRect - 29.IBEditorWindowLastContentRect - 29.IBPluginDependency - 29.ImportedFromIB2 - 29.WindowOrigin - 29.editorWindowContentRectSynchronizationRect - 295.IBPluginDependency - 296.IBEditorWindowLastContentRect - 296.IBPluginDependency - 296.editorWindowContentRectSynchronizationRect - 297.IBPluginDependency - 298.IBPluginDependency - 299.IBPluginDependency - 300.IBEditorWindowLastContentRect - 300.IBPluginDependency - 300.editorWindowContentRectSynchronizationRect - 344.IBPluginDependency - 345.IBPluginDependency - 346.IBPluginDependency - 346.ImportedFromIB2 - 348.IBPluginDependency - 348.ImportedFromIB2 - 349.IBEditorWindowLastContentRect - 349.IBPluginDependency - 349.ImportedFromIB2 - 349.editorWindowContentRectSynchronizationRect - 350.IBPluginDependency - 350.ImportedFromIB2 - 351.IBPluginDependency - 351.ImportedFromIB2 - 354.IBPluginDependency - 354.ImportedFromIB2 - 389.IBPluginDependency - 5.IBPluginDependency - 5.ImportedFromIB2 - 56.IBPluginDependency - 56.ImportedFromIB2 - 57.IBEditorWindowLastContentRect - 57.IBPluginDependency - 57.ImportedFromIB2 - 57.editorWindowContentRectSynchronizationRect - 58.IBPluginDependency - 58.ImportedFromIB2 - 72.IBPluginDependency - 72.ImportedFromIB2 - 73.IBPluginDependency - 73.ImportedFromIB2 - 74.IBPluginDependency - 74.ImportedFromIB2 - 75.IBPluginDependency - 75.ImportedFromIB2 - 77.IBPluginDependency - 77.ImportedFromIB2 - 78.IBPluginDependency - 78.ImportedFromIB2 - 79.IBPluginDependency - 79.ImportedFromIB2 - 80.IBPluginDependency - 80.ImportedFromIB2 - 81.IBEditorWindowLastContentRect - 81.IBPluginDependency - 81.ImportedFromIB2 - 81.editorWindowContentRectSynchronizationRect - 82.IBPluginDependency - 82.ImportedFromIB2 - 83.IBPluginDependency - 83.ImportedFromIB2 - 92.IBPluginDependency - 92.ImportedFromIB2 - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - {{906, 713}, {164, 23}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{375, 955}, {171, 23}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{522, 812}, {146, 23}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{436, 809}, {64, 6}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{915, 473}, {272, 83}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{608, 612}, {275, 83}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{675, 493}, {240, 243}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{144, 735}, {243, 243}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{915, 473}, {164, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{608, 612}, {167, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{915, 473}, {238, 103}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{608, 612}, {241, 103}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{835, 663}, {194, 73}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{304, 905}, {197, 73}} - {{541, 736}, {426, 20}} - com.apple.InterfaceBuilder.CocoaPlugin - - {74, 862} - {{6, 836}, {430, 20}} - com.apple.InterfaceBuilder.CocoaPlugin - {{785, 693}, {231, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - {{254, 935}, {234, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{719, 693}, {173, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - {{188, 935}, {176, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{915, 473}, {212, 63}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{608, 612}, {215, 63}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{553, 553}, {193, 183}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{18, 653}, {200, 183}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{633, 533}, {196, 203}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{102, 775}, {199, 203}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - - - - YES - - - YES - - - - - YES - - - YES - - - - 439 - - - - YES - - NSApplication - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSApplication.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSApplicationScripting.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSColorPanel.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSHelpManager.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSPageLayout.h - - - - NSBrowser - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSBrowser.h - - - - NSControl - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSControl.h - - - - NSController - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSController.h - - - - NSDocument - NSObject - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - id - id - id - id - id - id - - - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - - printDocument: - id - - - revertDocumentToSaved: - id - - - runPageLayout: - id - - - saveDocument: - id - - - saveDocumentAs: - id - - - saveDocumentTo: - id - - - - - IBFrameworkSource - AppKit.framework/Headers/NSDocument.h - - - - NSDocument - - IBFrameworkSource - AppKit.framework/Headers/NSDocumentScripting.h - - - - NSDocumentController - NSObject - - YES - - YES - clearRecentDocuments: - newDocument: - openDocument: - saveAllDocuments: - - - YES - id - id - id - id - - - - YES - - YES - clearRecentDocuments: - newDocument: - openDocument: - saveAllDocuments: - - - YES - - clearRecentDocuments: - id - - - newDocument: - id - - - openDocument: - id - - - saveAllDocuments: - id - - - - - IBFrameworkSource - AppKit.framework/Headers/NSDocumentController.h - - - - NSFormatter - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFormatter.h - - - - NSMatrix - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSMatrix.h - - - - NSMenu - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenu.h - - - - NSMenuItem - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenuItem.h - - - - NSMovieView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSMovieView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSAccessibility.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSAlert.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSAnimation.h - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSComboBox.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSComboBoxCell.h - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDatePickerCell.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDictionaryController.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDragging.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDrawer.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontManager.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontPanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSImage.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSKeyValueBinding.h - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSNibLoading.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSOutlineView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSPasteboard.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSRuleEditor.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSavePanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSound.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSpeechRecognizer.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSpeechSynthesizer.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSplitView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTabView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSText.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTextStorage.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTextView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTokenField.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTokenFieldCell.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbar.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbarItem.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSWindow.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSConnection.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSError.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFileManager.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueObserving.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyedArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSMetadata.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSNetServices.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObject.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObjectScripting.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSPort.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSPortCoder.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSRunLoop.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptObjectSpecifiers.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptWhoseTests.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSSpellServer.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSStream.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSThread.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURL.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLConnection.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLDownload.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSXMLParser.h - - - - NSObject - - IBFrameworkSource - Print.framework/Headers/PDEPluginInterface.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CAAnimation.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CALayer.h - - - - NSObject - - IBFrameworkSource - QuartzCore.framework/Headers/CIImageProvider.h - - - - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSInterfaceStyle.h - - - - NSResponder - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSResponder.h - - - - NSTableView - NSControl - - - - NSText - NSView - - - - NSUserDefaultsController - NSController - - IBFrameworkSource - AppKit.framework/Headers/NSUserDefaultsController.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSClipView.h - - - - NSView - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSRulerView.h - - - - NSView - NSResponder - - - - NSWindow - - - - NSWindow - NSResponder - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSWindowScripting.h - - - - - 0 - IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 - - - YES - ../../../../cef.xcodeproj - 3 - - YES - - YES - NSMenuCheckmark - NSMenuMixedState - - - YES - {9, 8} - {7, 2} - - - - diff --git a/tests/unittests/mac/Info.plist b/tests/unittests/mac/Info.plist deleted file mode 100644 index 3d5f27c20..000000000 --- a/tests/unittests/mac/Info.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - unittests.icns - CFBundleIdentifier - org.cef.unittests - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleSignature - ???? - CFBundleVersion - 1.0 - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/tests/unittests/mac/unittests.icns b/tests/unittests/mac/unittests.icns deleted file mode 100644 index f36742de2..000000000 Binary files a/tests/unittests/mac/unittests.icns and /dev/null differ diff --git a/tests/unittests/navigation_unittest.cc b/tests/unittests/navigation_unittest.cc deleted file mode 100644 index a830314ff..000000000 --- a/tests/unittests/navigation_unittest.cc +++ /dev/null @@ -1,605 +0,0 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "include/cef_callback.h" -#include "include/cef_scheme.h" -#include "tests/unittests/test_handler.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -static const char* kNav1 = "http://tests/nav1.html"; -static const char* kNav2 = "http://tests/nav2.html"; -static const char* kNav3 = "http://tests/nav3.html"; -static const char* kNav4 = "http://tests/nav4.html"; - -enum NavAction { - NA_LOAD = 1, - NA_BACK, - NA_FORWARD, - NA_CLEAR -}; - -typedef struct { - NavAction action; // What to do - const char* target; // Where to be after navigation - bool can_go_back; // After navigation, can go back? - bool can_go_forward; // After navigation, can go forward? -} NavListItem; - -// Array of navigation actions: X = current page, . = history exists -static NavListItem kNavList[] = { - // kNav1 | kNav2 | kNav3 - {NA_LOAD, kNav1, false, false}, // X - {NA_LOAD, kNav2, true, false}, // . X - {NA_BACK, kNav1, false, true}, // X . - {NA_FORWARD, kNav2, true, false}, // . X - {NA_LOAD, kNav3, true, false}, // . . X - {NA_BACK, kNav2, true, true}, // . X . - // TODO(cef): Enable once ClearHistory is implemented - // {NA_CLEAR, kNav2, false, false}, // X -}; - -#define NAV_LIST_SIZE() (sizeof(kNavList) / sizeof(NavListItem)) - -class HistoryNavTestHandler : public TestHandler { - public: - HistoryNavTestHandler() : nav_(0) {} - - virtual void RunTest() OVERRIDE { - // Add the resources that we will navigate to/from. - AddResource(kNav1, "Nav1", "text/html"); - AddResource(kNav2, "Nav2", "text/html"); - AddResource(kNav3, "Nav3", "text/html"); - - // Create the browser. - CreateBrowser(CefString()); - } - - void RunNav(CefRefPtr browser) { - if (nav_ == NAV_LIST_SIZE()) { - // End of the nav list. - DestroyTest(); - return; - } - - const NavListItem& item = kNavList[nav_]; - - // Perform the action. - switch (item.action) { - case NA_LOAD: - browser->GetMainFrame()->LoadURL(item.target); - break; - case NA_BACK: - browser->GoBack(); - break; - case NA_FORWARD: - browser->GoForward(); - break; - case NA_CLEAR: - // TODO(cef): Enable once ClearHistory is implemented - // browser->GetHost()->ClearHistory(); - // Not really a navigation action so go to the next one. - nav_++; - RunNav(browser); - break; - default: - break; - } - } - - virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE { - TestHandler::OnAfterCreated(browser); - - RunNav(browser); - } - - virtual bool OnBeforeResourceLoad(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request) OVERRIDE { - const NavListItem& item = kNavList[nav_]; - - got_before_resource_load_[nav_].yes(); - - std::string url = request->GetURL(); - if (url == item.target) - got_correct_target_[nav_].yes(); - - return false; - } - - virtual void OnLoadingStateChange(CefRefPtr browser, - bool isLoading, - bool canGoBack, - bool canGoForward) OVERRIDE { - const NavListItem& item = kNavList[nav_]; - - got_loading_state_change_[nav_].yes(); - - if (item.can_go_back == canGoBack) - got_correct_can_go_back_[nav_].yes(); - if (item.can_go_forward == canGoForward) - got_correct_can_go_forward_[nav_].yes(); - } - - virtual void OnLoadStart(CefRefPtr browser, - CefRefPtr frame) OVERRIDE { - if(browser->IsPopup() || !frame->IsMain()) - return; - - const NavListItem& item = kNavList[nav_]; - - got_load_start_[nav_].yes(); - - std::string url1 = browser->GetMainFrame()->GetURL(); - std::string url2 = frame->GetURL(); - if (url1 == item.target && url2 == item.target) - got_correct_load_start_url_[nav_].yes(); - } - - virtual void OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) OVERRIDE { - if (browser->IsPopup() || !frame->IsMain()) - return; - - const NavListItem& item = kNavList[nav_]; - - got_load_end_[nav_].yes(); - - std::string url1 = browser->GetMainFrame()->GetURL(); - std::string url2 = frame->GetURL(); - if (url1 == item.target && url2 == item.target) - got_correct_load_end_url_[nav_].yes(); - - if (item.can_go_back == browser->CanGoBack()) - got_correct_can_go_back2_[nav_].yes(); - if (item.can_go_forward == browser->CanGoForward()) - got_correct_can_go_forward2_[nav_].yes(); - - nav_++; - RunNav(browser); - } - - int nav_; - - TrackCallback got_before_resource_load_[NAV_LIST_SIZE()]; - TrackCallback got_correct_target_[NAV_LIST_SIZE()]; - TrackCallback got_loading_state_change_[NAV_LIST_SIZE()]; - TrackCallback got_correct_can_go_back_[NAV_LIST_SIZE()]; - TrackCallback got_correct_can_go_forward_[NAV_LIST_SIZE()]; - TrackCallback got_load_start_[NAV_LIST_SIZE()]; - TrackCallback got_correct_load_start_url_[NAV_LIST_SIZE()]; - TrackCallback got_load_end_[NAV_LIST_SIZE()]; - TrackCallback got_correct_load_end_url_[NAV_LIST_SIZE()]; - TrackCallback got_correct_can_go_back2_[NAV_LIST_SIZE()]; - TrackCallback got_correct_can_go_forward2_[NAV_LIST_SIZE()]; -}; - -} // namespace - -// Verify history navigation. -TEST(NavigationTest, History) { - CefRefPtr handler = - new HistoryNavTestHandler(); - handler->ExecuteTest(); - - for (size_t i = 0; i < NAV_LIST_SIZE(); ++i) { - if (kNavList[i].action != NA_CLEAR) { - ASSERT_TRUE(handler->got_before_resource_load_[i]) << "i = " << i; - ASSERT_TRUE(handler->got_correct_target_[i]) << "i = " << i; - ASSERT_TRUE(handler->got_load_start_[i]) << "i = " << i; - ASSERT_TRUE(handler->got_correct_load_start_url_[i]) << "i = " << i; - } - - ASSERT_TRUE(handler->got_loading_state_change_[i]) << "i = " << i; - ASSERT_TRUE(handler->got_correct_can_go_back_[i]) << "i = " << i; - ASSERT_TRUE(handler->got_correct_can_go_forward_[i]) << "i = " << i; - - if (kNavList[i].action != NA_CLEAR) { - ASSERT_TRUE(handler->got_load_end_[i]) << "i = " << i; - ASSERT_TRUE(handler->got_correct_load_end_url_[i]) << "i = " << i; - ASSERT_TRUE(handler->got_correct_can_go_back2_[i]) << "i = " << i; - ASSERT_TRUE(handler->got_correct_can_go_forward2_[i]) << "i = " << i; - } - } -} - - -namespace { - -class FrameNameIdentNavTestHandler : public TestHandler { - public: - FrameNameIdentNavTestHandler() : browse_ct_(0) {} - - virtual void RunTest() OVERRIDE { - // Add the frame resources. - std::stringstream ss; - - // Page with named frame - ss << "Nav1" - "", "text/html"); - AddResource(kV8ContextChildTestUrl, "CHILD", - "text/html"); - CreateBrowser(kV8ContextParentTestUrl); - } else { - EXPECT_TRUE(test_url_ != NULL); - AddResource(test_url_, "TEST", "text/html"); - CreateBrowser(test_url_); - } - } - - CefRefPtr CreateTestMessage() { - CefRefPtr msg = CefProcessMessage::Create(kV8TestMsg); - EXPECT_TRUE(msg->GetArgumentList()->SetInt(0, test_mode_)); - return msg; - } - - virtual void OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) OVERRIDE { - if (frame->IsMain()) { - // Send the message to the renderer process to run the test. - EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, - CreateTestMessage())); - } - } - - virtual bool OnProcessMessageReceived( - CefRefPtr browser, - CefProcessId source_process, - CefRefPtr message) OVERRIDE { - EXPECT_TRUE(browser.get()); - EXPECT_EQ(PID_RENDERER, source_process); - EXPECT_TRUE(message.get()); - EXPECT_TRUE(message->IsReadOnly()); - - got_message_.yes(); - - if (message->GetArgumentList()->GetBool(0)) - got_success_.yes(); - - // Test is complete. - DestroyTest(); - - return true; - } - - V8TestMode test_mode_; - const char* test_url_; - TrackCallback got_message_; - TrackCallback got_success_; -}; - -} // namespace - - -// Entry point for creating V8 renderer test objects. -// Called from client_app_delegates.cc. -void CreateV8RendererTests(ClientApp::RenderDelegateSet& delegates) { - delegates.insert(new V8RendererTest); -} - - -// Helpers for defining V8 tests. -#define V8_TEST_EX(name, test_mode, test_url) \ - TEST(V8Test, name) { \ - CefRefPtr handler = \ - new V8TestHandler(test_mode, test_url); \ - handler->ExecuteTest(); \ - EXPECT_TRUE(handler->got_message_); \ - EXPECT_TRUE(handler->got_success_); \ - } - -#define V8_TEST(name, test_mode) \ - V8_TEST_EX(name, test_mode, kV8TestUrl) - - -// Define the tests. -V8_TEST(NullCreate, V8TEST_NULL_CREATE); -V8_TEST(BoolCreate, V8TEST_BOOL_CREATE); -V8_TEST(IntCreate, V8TEST_INT_CREATE); -V8_TEST(UIntCreate, V8TEST_UINT_CREATE); -V8_TEST(DoubleCreate, V8TEST_DOUBLE_CREATE); -V8_TEST(DateCreate, V8TEST_DATE_CREATE); -V8_TEST(StringCreate, V8TEST_STRING_CREATE); -V8_TEST(ArrayCreate, V8TEST_ARRAY_CREATE); -V8_TEST(ArrayValue, V8TEST_ARRAY_VALUE); -V8_TEST(ObjectCreate, V8TEST_OBJECT_CREATE); -V8_TEST(ObjectUserData, V8TEST_OBJECT_USERDATA); -V8_TEST(ObjectAccessor, V8TEST_OBJECT_ACCESSOR); -V8_TEST(ObjectAccessorException, V8TEST_OBJECT_ACCESSOR_EXCEPTION); -V8_TEST(ObjectAccessorFail, V8TEST_OBJECT_ACCESSOR_FAIL); -V8_TEST(ObjectAccessorReadOnly, V8TEST_OBJECT_ACCESSOR_READONLY); -V8_TEST(ObjectValue, V8TEST_OBJECT_VALUE); -V8_TEST(ObjectValueReadOnly, V8TEST_OBJECT_VALUE_READONLY); -V8_TEST(ObjectValueEnum, V8TEST_OBJECT_VALUE_ENUM); -V8_TEST(ObjectValueDontEnum, V8TEST_OBJECT_VALUE_DONTENUM); -V8_TEST(ObjectValueDelete, V8TEST_OBJECT_VALUE_DELETE); -V8_TEST(ObjectValueDontDelete, V8TEST_OBJECT_VALUE_DONTDELETE); -V8_TEST(FunctionCreate, V8TEST_FUNCTION_CREATE); -V8_TEST(FunctionHandler, V8TEST_FUNCTION_HANDLER); -V8_TEST(FunctionHandlerException, V8TEST_FUNCTION_HANDLER_EXCEPTION); -V8_TEST(FunctionHandlerFail, V8TEST_FUNCTION_HANDLER_FAIL); -V8_TEST(FunctionHandlerNoObject, V8TEST_FUNCTION_HANDLER_NO_OBJECT); -V8_TEST(FunctionHandlerWithContext, V8TEST_FUNCTION_HANDLER_WITH_CONTEXT); -V8_TEST(ContextEval, V8TEST_CONTEXT_EVAL); -V8_TEST(ContextEvalException, V8TEST_CONTEXT_EVAL_EXCEPTION); -V8_TEST_EX(ContextEntered, V8TEST_CONTEXT_ENTERED, NULL); -V8_TEST_EX(Binding, V8TEST_BINDING, kV8BindingTestUrl); diff --git a/tests/unittests/values_unittest.cc b/tests/unittests/values_unittest.cc deleted file mode 100644 index 3e3cb83ad..000000000 --- a/tests/unittests/values_unittest.cc +++ /dev/null @@ -1,734 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "include/cef_task.h" -#include "include/cef_values.h" -#include "tests/unittests/test_handler.h" -#include "tests/unittests/test_util.h" -#include "testing/gtest/include/gtest/gtest.h" - - -namespace { - -// Dictionary test keys. -const char* kNullKey = "null_key"; -const char* kBoolKey = "bool_key"; -const char* kIntKey = "int_key"; -const char* kDoubleKey = "double_key"; -const char* kStringKey = "string_key"; -const char* kBinaryKey = "binary_key"; -const char* kDictionaryKey = "dict_key"; -const char* kListKey = "list_key"; - -// List test indexes. -enum { - kNullIndex = 0, - kBoolIndex, - kIntIndex, - kDoubleIndex, - kStringIndex, - kBinaryIndex, - kDictionaryIndex, - kListIndex, -}; - -// Dictionary/list test values. -const bool kBoolValue = true; -const int kIntValue = 12; -const double kDoubleValue = 4.5432; -const char* kStringValue = "My string value"; - - -// BINARY TEST HELPERS - -// Test a binary value. -void TestBinary(CefRefPtr value, char* data, size_t data_size) { - // Testing requires strings longer than 15 characters. - EXPECT_GT(data_size, (size_t)15); - - EXPECT_EQ(data_size, value->GetSize()); - - char* buff = new char[data_size+1]; - char old_char; - - // Test full read. - memset(buff, 0, data_size+1); - EXPECT_EQ(data_size, value->GetData(buff, data_size, 0)); - EXPECT_TRUE(!strcmp(buff, data)); - - // Test partial read with offset. - memset(buff, 0, data_size+1); - old_char = data[15]; - data[15] = 0; - EXPECT_EQ((size_t)10, value->GetData(buff, 10, 5)); - EXPECT_TRUE(!strcmp(buff, data+5)); - data[15] = old_char; - - // Test that changes to the original data have no effect. - memset(buff, 0, data_size+1); - old_char = data[0]; - data[0] = '.'; - EXPECT_EQ((size_t)1, value->GetData(buff, 1, 0)); - EXPECT_EQ(old_char, buff[0]); - data[0] = old_char; - - // Test copy. - CefRefPtr copy = value->Copy(); - TestBinaryEqual(copy, value); - - delete [] buff; -} - -// Used to test access of binary data on a different thread. -class BinaryTask : public CefTask { - public: - BinaryTask(CefRefPtr value, char* data, size_t data_size) - : value_(value), - data_(data), - data_size_(data_size) {} - - virtual void Execute(CefThreadId threadId) OVERRIDE { - TestBinary(value_, data_, data_size_); - } - - private: - CefRefPtr value_; - char* data_; - size_t data_size_; - - IMPLEMENT_REFCOUNTING(BinaryTask); -}; - - -// DICTIONARY TEST HELPERS - -// Test dictionary null value. -void TestDictionaryNull(CefRefPtr value) { - EXPECT_FALSE(value->HasKey(kNullKey)); - EXPECT_TRUE(value->SetNull(kNullKey)); - EXPECT_TRUE(value->HasKey(kNullKey)); - EXPECT_EQ(VTYPE_NULL, value->GetType(kNullKey)); -} - -// Test dictionary bool value. -void TestDictionaryBool(CefRefPtr value) { - EXPECT_FALSE(value->HasKey(kBoolKey)); - EXPECT_TRUE(value->SetBool(kBoolKey, kBoolValue)); - EXPECT_TRUE(value->HasKey(kBoolKey)); - EXPECT_EQ(VTYPE_BOOL, value->GetType(kBoolKey)); - EXPECT_EQ(kBoolValue, value->GetBool(kBoolKey)); -} - -// Test dictionary int value. -void TestDictionaryInt(CefRefPtr value) { - EXPECT_FALSE(value->HasKey(kIntKey)); - EXPECT_TRUE(value->SetInt(kIntKey, kIntValue)); - EXPECT_TRUE(value->HasKey(kIntKey)); - EXPECT_EQ(VTYPE_INT, value->GetType(kIntKey)); - EXPECT_EQ(kIntValue, value->GetInt(kIntKey)); -} - -// Test dictionary double value. -void TestDictionaryDouble(CefRefPtr value) { - EXPECT_FALSE(value->HasKey(kDoubleKey)); - EXPECT_TRUE(value->SetDouble(kDoubleKey, kDoubleValue)); - EXPECT_TRUE(value->HasKey(kDoubleKey)); - EXPECT_EQ(VTYPE_DOUBLE, value->GetType(kDoubleKey)); - EXPECT_EQ(kDoubleValue, value->GetDouble(kDoubleKey)); -} - -// Test dictionary string value. -void TestDictionaryString(CefRefPtr value) { - EXPECT_FALSE(value->HasKey(kStringKey)); - EXPECT_TRUE(value->SetString(kStringKey, kStringValue)); - EXPECT_TRUE(value->HasKey(kStringKey)); - EXPECT_EQ(VTYPE_STRING, value->GetType(kStringKey)); - EXPECT_EQ(kStringValue, value->GetString(kStringKey).ToString()); -} - -// Test dictionary binary value. -void TestDictionaryBinary(CefRefPtr value, - char* binary_data, size_t binary_data_size, - CefRefPtr& binary_value) { - binary_value = CefBinaryValue::Create(binary_data, binary_data_size); - EXPECT_TRUE(binary_value.get()); - EXPECT_TRUE(binary_value->IsValid()); - EXPECT_FALSE(binary_value->IsOwned()); - EXPECT_FALSE(value->HasKey(kBinaryKey)); - EXPECT_TRUE(value->SetBinary(kBinaryKey, binary_value)); - EXPECT_FALSE(binary_value->IsValid()); // Value should be detached - EXPECT_TRUE(value->HasKey(kBinaryKey)); - EXPECT_EQ(VTYPE_BINARY, value->GetType(kBinaryKey)); - binary_value = value->GetBinary(kBinaryKey); - EXPECT_TRUE(binary_value.get()); - EXPECT_TRUE(binary_value->IsValid()); - EXPECT_TRUE(binary_value->IsOwned()); - TestBinary(binary_value, binary_data, binary_data_size); -} - -// Test dictionary dictionary value. -void TestDictionaryDictionary(CefRefPtr value, - CefRefPtr& dictionary_value) { - dictionary_value = CefDictionaryValue::Create(); - EXPECT_TRUE(dictionary_value.get()); - EXPECT_TRUE(dictionary_value->IsValid()); - EXPECT_FALSE(dictionary_value->IsOwned()); - EXPECT_FALSE(dictionary_value->IsReadOnly()); - EXPECT_TRUE(dictionary_value->SetInt(kIntKey, kIntValue)); - EXPECT_EQ((size_t)1, dictionary_value->GetSize()); - EXPECT_FALSE(value->HasKey(kDictionaryKey)); - EXPECT_TRUE(value->SetDictionary(kDictionaryKey, dictionary_value)); - EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached - EXPECT_TRUE(value->HasKey(kDictionaryKey)); - EXPECT_EQ(VTYPE_DICTIONARY, value->GetType(kDictionaryKey)); - dictionary_value = value->GetDictionary(kDictionaryKey); - EXPECT_TRUE(dictionary_value.get()); - EXPECT_TRUE(dictionary_value->IsValid()); - EXPECT_TRUE(dictionary_value->IsOwned()); - EXPECT_FALSE(dictionary_value->IsReadOnly()); - EXPECT_EQ((size_t)1, dictionary_value->GetSize()); - EXPECT_EQ(kIntValue, dictionary_value->GetInt(kIntKey)); -} - -// Test dictionary list value. -void TestDictionaryList(CefRefPtr value, - CefRefPtr& list_value) { - list_value = CefListValue::Create(); - EXPECT_TRUE(list_value.get()); - EXPECT_TRUE(list_value->IsValid()); - EXPECT_FALSE(list_value->IsOwned()); - EXPECT_FALSE(list_value->IsReadOnly()); - EXPECT_TRUE(list_value->SetInt(0, kIntValue)); - EXPECT_EQ((size_t)1, list_value->GetSize()); - EXPECT_FALSE(value->HasKey(kListKey)); - EXPECT_TRUE(value->SetList(kListKey, list_value)); - EXPECT_FALSE(list_value->IsValid()); // Value should be detached - EXPECT_TRUE(value->HasKey(kListKey)); - EXPECT_EQ(VTYPE_LIST, value->GetType(kListKey)); - list_value = value->GetList(kListKey); - EXPECT_TRUE(list_value.get()); - EXPECT_TRUE(list_value->IsValid()); - EXPECT_TRUE(list_value->IsOwned()); - EXPECT_FALSE(list_value->IsReadOnly()); - EXPECT_EQ((size_t)1, list_value->GetSize()); - EXPECT_EQ(kIntValue, list_value->GetInt(0)); -} - -// Test dictionary value. -void TestDictionary(CefRefPtr value, - char* binary_data, size_t binary_data_size) { - CefRefPtr binary_value; - CefRefPtr dictionary_value; - CefRefPtr list_value; - - // Test the size. - EXPECT_EQ((size_t)0, value->GetSize()); - - TestDictionaryNull(value); - TestDictionaryBool(value); - TestDictionaryInt(value); - TestDictionaryDouble(value); - TestDictionaryString(value); - TestDictionaryBinary(value, binary_data, binary_data_size, binary_value); - TestDictionaryDictionary(value, dictionary_value); - TestDictionaryList(value, list_value); - - // Test the size. - EXPECT_EQ((size_t)8, value->GetSize()); - - // Test copy. - CefRefPtr copy = value->Copy(false); - TestDictionaryEqual(value, copy); - - // Test removal. - EXPECT_TRUE(value->Remove(kNullKey)); - EXPECT_FALSE(value->HasKey(kNullKey)); - - EXPECT_TRUE(value->Remove(kBoolKey)); - EXPECT_FALSE(value->HasKey(kBoolKey)); - - EXPECT_TRUE(value->Remove(kIntKey)); - EXPECT_FALSE(value->HasKey(kIntKey)); - - EXPECT_TRUE(value->Remove(kDoubleKey)); - EXPECT_FALSE(value->HasKey(kDoubleKey)); - - EXPECT_TRUE(value->Remove(kStringKey)); - EXPECT_FALSE(value->HasKey(kStringKey)); - - EXPECT_TRUE(value->Remove(kBinaryKey)); - EXPECT_FALSE(value->HasKey(kBinaryKey)); - EXPECT_FALSE(binary_value->IsValid()); // Value should be detached - - EXPECT_TRUE(value->Remove(kDictionaryKey)); - EXPECT_FALSE(value->HasKey(kDictionaryKey)); - EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached - - EXPECT_TRUE(value->Remove(kListKey)); - EXPECT_FALSE(value->HasKey(kListKey)); - EXPECT_FALSE(list_value->IsValid()); // Value should be detached - - // Test the size. - EXPECT_EQ((size_t)0, value->GetSize()); - - // Re-add some values. - TestDictionaryNull(value); - TestDictionaryBool(value); - TestDictionaryDictionary(value, dictionary_value); - - // Test the size. - EXPECT_EQ((size_t)3, value->GetSize()); - - // Clear the values. - EXPECT_TRUE(value->Clear()); - EXPECT_EQ((size_t)0, value->GetSize()); - EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached -} - -// Used to test access of dictionary data on a different thread. -class DictionaryTask : public CefTask { - public: - DictionaryTask(CefRefPtr value, char* binary_data, - size_t binary_data_size) - : value_(value), - binary_data_(binary_data), - binary_data_size_(binary_data_size) {} - - virtual void Execute(CefThreadId threadId) OVERRIDE { - TestDictionary(value_, binary_data_, binary_data_size_); - } - - private: - CefRefPtr value_; - char* binary_data_; - size_t binary_data_size_; - - IMPLEMENT_REFCOUNTING(DictionaryTask); -}; - - -// LIST TEST HELPERS - -// Test list null value. -void TestListNull(CefRefPtr value, int index) { - CefValueType type = value->GetType(index); - EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); - - EXPECT_TRUE(value->SetNull(index)); - EXPECT_EQ(VTYPE_NULL, value->GetType(index)); -} - -// Test list bool value. -void TestListBool(CefRefPtr value, int index) { - CefValueType type = value->GetType(index); - EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); - - EXPECT_TRUE(value->SetBool(index, kBoolValue)); - EXPECT_EQ(VTYPE_BOOL, value->GetType(index)); - EXPECT_EQ(kBoolValue, value->GetBool(index)); -} - -// Test list int value. -void TestListInt(CefRefPtr value, int index) { - CefValueType type = value->GetType(index); - EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); - - EXPECT_TRUE(value->SetInt(index, kIntValue)); - EXPECT_EQ(VTYPE_INT, value->GetType(index)); - EXPECT_EQ(kIntValue, value->GetInt(index)); -} - -// Test list double value. -void TestListDouble(CefRefPtr value, int index) { - CefValueType type = value->GetType(index); - EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); - - EXPECT_TRUE(value->SetDouble(index, kDoubleValue)); - EXPECT_EQ(VTYPE_DOUBLE, value->GetType(index)); - EXPECT_EQ(kDoubleValue, value->GetDouble(index)); -} - -// Test list string value. -void TestListString(CefRefPtr value, int index) { - CefValueType type = value->GetType(index); - EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); - - EXPECT_TRUE(value->SetString(index, kStringValue)); - EXPECT_EQ(VTYPE_STRING, value->GetType(index)); - EXPECT_EQ(kStringValue, value->GetString(index).ToString()); -} - -// Test list binary value. -void TestListBinary(CefRefPtr value, int index, - char* binary_data, size_t binary_data_size, - CefRefPtr& binary_value) { - binary_value = CefBinaryValue::Create(binary_data, binary_data_size); - EXPECT_TRUE(binary_value.get()); - EXPECT_TRUE(binary_value->IsValid()); - EXPECT_FALSE(binary_value->IsOwned()); - - CefValueType type = value->GetType(index); - EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); - - EXPECT_TRUE(value->SetBinary(index, binary_value)); - EXPECT_FALSE(binary_value->IsValid()); // Value should be detached - EXPECT_EQ(VTYPE_BINARY, value->GetType(index)); - binary_value = value->GetBinary(index); - EXPECT_TRUE(binary_value.get()); - EXPECT_TRUE(binary_value->IsValid()); - EXPECT_TRUE(binary_value->IsOwned()); - TestBinary(binary_value, binary_data, binary_data_size); -} - -// Test list dictionary value. -void TestListDictionary(CefRefPtr value, int index, - CefRefPtr& dictionary_value) { - dictionary_value = CefDictionaryValue::Create(); - EXPECT_TRUE(dictionary_value.get()); - EXPECT_TRUE(dictionary_value->IsValid()); - EXPECT_FALSE(dictionary_value->IsOwned()); - EXPECT_FALSE(dictionary_value->IsReadOnly()); - EXPECT_TRUE(dictionary_value->SetInt(kIntKey, kIntValue)); - EXPECT_EQ((size_t)1, dictionary_value->GetSize()); - - CefValueType type = value->GetType(index); - EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); - - EXPECT_TRUE(value->SetDictionary(index, dictionary_value)); - EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached - EXPECT_EQ(VTYPE_DICTIONARY, value->GetType(index)); - dictionary_value = value->GetDictionary(index); - EXPECT_TRUE(dictionary_value.get()); - EXPECT_TRUE(dictionary_value->IsValid()); - EXPECT_TRUE(dictionary_value->IsOwned()); - EXPECT_FALSE(dictionary_value->IsReadOnly()); - EXPECT_EQ((size_t)1, dictionary_value->GetSize()); - EXPECT_EQ(kIntValue, dictionary_value->GetInt(kIntKey)); -} - -// Test list list value. -void TestListList(CefRefPtr value, int index, - CefRefPtr& list_value) { - list_value = CefListValue::Create(); - EXPECT_TRUE(list_value.get()); - EXPECT_TRUE(list_value->IsValid()); - EXPECT_FALSE(list_value->IsOwned()); - EXPECT_FALSE(list_value->IsReadOnly()); - EXPECT_TRUE(list_value->SetInt(0, kIntValue)); - EXPECT_EQ((size_t)1, list_value->GetSize()); - - CefValueType type = value->GetType(index); - EXPECT_TRUE(type == VTYPE_INVALID || type == VTYPE_NULL); - - EXPECT_TRUE(value->SetList(index, list_value)); - EXPECT_FALSE(list_value->IsValid()); // Value should be detached - EXPECT_EQ(VTYPE_LIST, value->GetType(index)); - list_value = value->GetList(index); - EXPECT_TRUE(list_value.get()); - EXPECT_TRUE(list_value->IsValid()); - EXPECT_TRUE(list_value->IsOwned()); - EXPECT_FALSE(list_value->IsReadOnly()); - EXPECT_EQ((size_t)1, list_value->GetSize()); - EXPECT_EQ(kIntValue, list_value->GetInt(0)); -} - -// Test list value. -void TestList(CefRefPtr value, - char* binary_data, size_t binary_data_size) { - CefRefPtr binary_value; - CefRefPtr dictionary_value; - CefRefPtr list_value; - - // Test the size. - EXPECT_EQ((size_t)0, value->GetSize()); - - // Set the size. - EXPECT_TRUE(value->SetSize(8)); - EXPECT_EQ((size_t)8, value->GetSize()); - - EXPECT_EQ(VTYPE_NULL, value->GetType(kNullIndex)); - TestListNull(value, kNullIndex); - EXPECT_EQ(VTYPE_NULL, value->GetType(kBoolIndex)); - TestListBool(value, kBoolIndex); - EXPECT_EQ(VTYPE_NULL, value->GetType(kIntIndex)); - TestListInt(value, kIntIndex); - EXPECT_EQ(VTYPE_NULL, value->GetType(kDoubleIndex)); - TestListDouble(value, kDoubleIndex); - EXPECT_EQ(VTYPE_NULL, value->GetType(kStringIndex)); - TestListString(value, kStringIndex); - EXPECT_EQ(VTYPE_NULL, value->GetType(kBinaryIndex)); - TestListBinary(value, kBinaryIndex, binary_data, binary_data_size, - binary_value); - EXPECT_EQ(VTYPE_NULL, value->GetType(kDictionaryIndex)); - TestListDictionary(value, kDictionaryIndex, dictionary_value); - EXPECT_EQ(VTYPE_NULL, value->GetType(kListIndex)); - TestListList(value, kListIndex, list_value); - - // Test the size. - EXPECT_EQ((size_t)8, value->GetSize()); - - // Test copy. - CefRefPtr copy = value->Copy(); - TestListEqual(value, copy); - - // Test removal (in reverse order so indexes stay valid). - EXPECT_TRUE(value->Remove(kListIndex)); - EXPECT_EQ((size_t)7, value->GetSize()); - EXPECT_FALSE(list_value->IsValid()); // Value should be detached - - EXPECT_TRUE(value->Remove(kDictionaryIndex)); - EXPECT_EQ((size_t)6, value->GetSize()); - EXPECT_FALSE(dictionary_value->IsValid()); // Value should be detached - - EXPECT_TRUE(value->Remove(kBinaryIndex)); - EXPECT_EQ((size_t)5, value->GetSize()); - EXPECT_FALSE(binary_value->IsValid()); // Value should be detached - - EXPECT_TRUE(value->Remove(kStringIndex)); - EXPECT_EQ((size_t)4, value->GetSize()); - - EXPECT_TRUE(value->Remove(kDoubleIndex)); - EXPECT_EQ((size_t)3, value->GetSize()); - - EXPECT_TRUE(value->Remove(kIntIndex)); - EXPECT_EQ((size_t)2, value->GetSize()); - - EXPECT_TRUE(value->Remove(kBoolIndex)); - EXPECT_EQ((size_t)1, value->GetSize()); - - EXPECT_TRUE(value->Remove(kNullIndex)); - EXPECT_EQ((size_t)0, value->GetSize()); - - // Re-add some values. - EXPECT_EQ(VTYPE_INVALID, value->GetType(0)); - TestListNull(value, 0); - EXPECT_EQ(VTYPE_INVALID, value->GetType(1)); - TestListBool(value, 1); - EXPECT_EQ(VTYPE_INVALID, value->GetType(2)); - TestListList(value, 2, list_value); - - // Test the size. - EXPECT_EQ((size_t)3, value->GetSize()); - - // Clear the values. - EXPECT_TRUE(value->Clear()); - EXPECT_EQ((size_t)0, value->GetSize()); - EXPECT_FALSE(list_value->IsValid()); // Value should be detached - - // Add some values in random order. - EXPECT_EQ(VTYPE_INVALID, value->GetType(2)); - TestListInt(value, 2); - EXPECT_EQ(VTYPE_NULL, value->GetType(0)); - TestListBool(value, 0); - EXPECT_EQ(VTYPE_NULL, value->GetType(1)); - TestListList(value, 1, list_value); - - EXPECT_EQ(VTYPE_BOOL, value->GetType(0)); - EXPECT_EQ(VTYPE_LIST, value->GetType(1)); - EXPECT_EQ(VTYPE_INT, value->GetType(2)); - - // Test the size. - EXPECT_EQ((size_t)3, value->GetSize()); - - // Clear some values. - EXPECT_TRUE(value->SetSize(1)); - EXPECT_EQ((size_t)1, value->GetSize()); - EXPECT_FALSE(list_value->IsValid()); // Value should be detached - - EXPECT_EQ(VTYPE_BOOL, value->GetType(0)); - EXPECT_EQ(VTYPE_INVALID, value->GetType(1)); - EXPECT_EQ(VTYPE_INVALID, value->GetType(2)); - - // Clear all values. - EXPECT_TRUE(value->Clear()); - EXPECT_EQ((size_t)0, value->GetSize()); -} - -// Used to test access of list data on a different thread. -class ListTask : public CefTask { - public: - ListTask(CefRefPtr value, char* binary_data, - size_t binary_data_size) - : value_(value), - binary_data_(binary_data), - binary_data_size_(binary_data_size) {} - - virtual void Execute(CefThreadId threadId) OVERRIDE { - TestList(value_, binary_data_, binary_data_size_); - } - - private: - CefRefPtr value_; - char* binary_data_; - size_t binary_data_size_; - - IMPLEMENT_REFCOUNTING(ListTask); -}; - -} // namespace - - -// Test binary value access. -TEST(ValuesTest, BinaryAccess) { - char data[] = "This is my test data"; - - CefRefPtr value = - CefBinaryValue::Create(data, sizeof(data)-1); - EXPECT_TRUE(value.get()); - EXPECT_TRUE(value->IsValid()); - EXPECT_FALSE(value->IsOwned()); - - // Test on this thread. - TestBinary(value, data, sizeof(data)-1); -} - -// Test binary value access on a different thread. -TEST(ValuesTest, BinaryAccessOtherThread) { - char data[] = "This is my test data"; - - CefRefPtr value = - CefBinaryValue::Create(data, sizeof(data)-1); - EXPECT_TRUE(value.get()); - EXPECT_TRUE(value->IsValid()); - EXPECT_FALSE(value->IsOwned()); - - // Test on a different thread. - CefPostTask(TID_UI, new BinaryTask(value, data, sizeof(data)-1)); - WaitForUIThread(); -} - -// Test dictionary value access. -TEST(ValuesTest, DictionaryAccess) { - CefRefPtr value = CefDictionaryValue::Create(); - EXPECT_TRUE(value.get()); - EXPECT_TRUE(value->IsValid()); - EXPECT_FALSE(value->IsOwned()); - EXPECT_FALSE(value->IsReadOnly()); - - char binary_data[] = "This is my test data"; - - // Test on this thread. - TestDictionary(value, binary_data, sizeof(binary_data)-1); -} - -// Test dictionary value access on a different thread. -TEST(ValuesTest, DictionaryAccessOtherThread) { - CefRefPtr value = CefDictionaryValue::Create(); - EXPECT_TRUE(value.get()); - EXPECT_TRUE(value->IsValid()); - EXPECT_FALSE(value->IsOwned()); - EXPECT_FALSE(value->IsReadOnly()); - - char binary_data[] = "This is my test data"; - - // Test on a different thread. - CefPostTask(TID_UI, - new DictionaryTask(value, binary_data, sizeof(binary_data)-1)); - WaitForUIThread(); -} - -// Test dictionary value nested detachment -TEST(ValuesTest, DictionaryDetachment) { - CefRefPtr value = CefDictionaryValue::Create(); - EXPECT_TRUE(value.get()); - EXPECT_TRUE(value->IsValid()); - EXPECT_FALSE(value->IsOwned()); - EXPECT_FALSE(value->IsReadOnly()); - - CefRefPtr dictionary_value = CefDictionaryValue::Create(); - CefRefPtr dictionary_value2 = - CefDictionaryValue::Create(); - CefRefPtr dictionary_value3 = - CefDictionaryValue::Create(); - - dictionary_value2->SetDictionary(kDictionaryKey, dictionary_value3); - EXPECT_FALSE(dictionary_value3->IsValid()); - dictionary_value->SetDictionary(kDictionaryKey, dictionary_value2); - EXPECT_FALSE(dictionary_value2->IsValid()); - value->SetDictionary(kDictionaryKey, dictionary_value); - EXPECT_FALSE(dictionary_value->IsValid()); - - dictionary_value = value->GetDictionary(kDictionaryKey); - EXPECT_TRUE(dictionary_value.get()); - EXPECT_TRUE(dictionary_value->IsValid()); - - dictionary_value2 = dictionary_value->GetDictionary(kDictionaryKey); - EXPECT_TRUE(dictionary_value2.get()); - EXPECT_TRUE(dictionary_value2->IsValid()); - - dictionary_value3 = dictionary_value2->GetDictionary(kDictionaryKey); - EXPECT_TRUE(dictionary_value3.get()); - EXPECT_TRUE(dictionary_value3->IsValid()); - - EXPECT_TRUE(value->Remove(kDictionaryKey)); - EXPECT_FALSE(dictionary_value->IsValid()); - EXPECT_FALSE(dictionary_value2->IsValid()); - EXPECT_FALSE(dictionary_value3->IsValid()); -} - -// Test list value access. -TEST(ValuesTest, ListAccess) { - CefRefPtr value = CefListValue::Create(); - EXPECT_TRUE(value.get()); - EXPECT_TRUE(value->IsValid()); - EXPECT_FALSE(value->IsOwned()); - EXPECT_FALSE(value->IsReadOnly()); - - char binary_data[] = "This is my test data"; - - // Test on this thread. - TestList(value, binary_data, sizeof(binary_data)-1); -} - -// Test list value access on a different thread. -TEST(ValuesTest, ListAccessOtherThread) { - CefRefPtr value = CefListValue::Create(); - EXPECT_TRUE(value.get()); - EXPECT_TRUE(value->IsValid()); - EXPECT_FALSE(value->IsOwned()); - EXPECT_FALSE(value->IsReadOnly()); - - char binary_data[] = "This is my test data"; - - // Test on a different thread. - CefPostTask(TID_UI, new ListTask(value, binary_data, sizeof(binary_data)-1)); - WaitForUIThread(); -} - -// Test list value nested detachment -TEST(ValuesTest, ListDetachment) { - CefRefPtr value = CefListValue::Create(); - EXPECT_TRUE(value.get()); - EXPECT_TRUE(value->IsValid()); - EXPECT_FALSE(value->IsOwned()); - EXPECT_FALSE(value->IsReadOnly()); - - CefRefPtr list_value = CefListValue::Create(); - CefRefPtr list_value2 = CefListValue::Create(); - CefRefPtr list_value3 = CefListValue::Create(); - - list_value2->SetList(0, list_value3); - EXPECT_FALSE(list_value3->IsValid()); - list_value->SetList(0, list_value2); - EXPECT_FALSE(list_value2->IsValid()); - value->SetList(0, list_value); - EXPECT_FALSE(list_value->IsValid()); - - list_value = value->GetList(0); - EXPECT_TRUE(list_value.get()); - EXPECT_TRUE(list_value->IsValid()); - - list_value2 = list_value->GetList(0); - EXPECT_TRUE(list_value2.get()); - EXPECT_TRUE(list_value2->IsValid()); - - list_value3 = list_value2->GetList(0); - EXPECT_TRUE(list_value3.get()); - EXPECT_TRUE(list_value3->IsValid()); - - EXPECT_TRUE(value->Remove(0)); - EXPECT_FALSE(list_value->IsValid()); - EXPECT_FALSE(list_value2->IsValid()); - EXPECT_FALSE(list_value3->IsValid()); -} diff --git a/tests/unittests/xml_reader_unittest.cc b/tests/unittests/xml_reader_unittest.cc deleted file mode 100644 index fcc85600e..000000000 --- a/tests/unittests/xml_reader_unittest.cc +++ /dev/null @@ -1,642 +0,0 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "include/cef_stream.h" -#include "include/cef_xml_reader.h" -#include "include/wrapper/cef_xml_object.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -char g_test_xml[] = - "\n" - "\n" - "\n" - " \n" - "]>\n" - "\n" - " value A\n" - " \n" - " \n" - " value B1\n" - " data]]>\n" - " &EB;\n" - " this is mixed content &EA;\n" - " \n" - " " - "\n" - "\n"; - -} // namespace - -// Test XML reading -TEST(XmlReaderTest, Read) { - // Create the stream reader. - CefRefPtr stream( - CefStreamReader::CreateForData(g_test_xml, sizeof(g_test_xml) - 1)); - ASSERT_TRUE(stream.get() != NULL); - - // Create the XML reader. - CefRefPtr reader( - CefXmlReader::Create(stream, XML_ENCODING_NONE, - "http://www.example.org/example.xml")); - ASSERT_TRUE(reader.get() != NULL); - - // Move to the processing instruction node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 0); - ASSERT_EQ(reader->GetType(), XML_NODE_PROCESSING_INSTRUCTION); - ASSERT_EQ(reader->GetLocalName(), "my_instruction"); - ASSERT_EQ(reader->GetQualifiedName(), "my_instruction"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), "my_value"); - - // Move to the DOCTYPE node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 0); - ASSERT_EQ(reader->GetType(), XML_NODE_DOCUMENT_TYPE); - ASSERT_EQ(reader->GetLocalName(), "my_document"); - ASSERT_EQ(reader->GetQualifiedName(), "my_document"); - ASSERT_FALSE(reader->HasValue()); - - // Move to ns:obj element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 0); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "obj"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:obj"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_TRUE(reader->HasAttributes()); - ASSERT_EQ(reader->GetAttributeCount(), (size_t)1); - ASSERT_EQ(reader->GetAttribute(0), "http://www.example.org/ns"); - ASSERT_EQ(reader->GetAttribute("xmlns:ns"), "http://www.example.org/ns"); - ASSERT_EQ(reader->GetAttribute("ns", "http://www.w3.org/2000/xmlns/"), - "http://www.example.org/ns"); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the ns:objA element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "objA"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objA"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the ns:objA value node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_TEXT); - ASSERT_EQ(reader->GetLocalName(), "#text"); - ASSERT_EQ(reader->GetQualifiedName(), "#text"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), "value A"); - - // Move to the ns:objA element ending node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "objA"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objA"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the comment node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_COMMENT); - ASSERT_EQ(reader->GetLocalName(), "#comment"); - ASSERT_EQ(reader->GetQualifiedName(), "#comment"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), " my comment "); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the ns:objB element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "objB"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the ns:objB_1 element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "objB_1"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_1"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the ns:objB_1 value node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 3); - ASSERT_EQ(reader->GetType(), XML_NODE_TEXT); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), "value B1"); - - // Move to the ns:objB_1 element ending node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "objB_1"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_1"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the ns:objB_2 element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "objB_2"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_2"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the ns:objB_2 value node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 3); - ASSERT_EQ(reader->GetType(), XML_NODE_CDATA); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), "some
data"); - - // Move to the ns:objB_2 element ending node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "objB_2"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_2"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the ns:objB_3 element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "objB_3"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_3"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the EB entity reference node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 3); - ASSERT_EQ(reader->GetType(), XML_NODE_ENTITY_REFERENCE); - ASSERT_EQ(reader->GetLocalName(), "EB"); - ASSERT_EQ(reader->GetQualifiedName(), "EB"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), "EB Value"); - - // Move to the ns:objB_3 element ending node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "objB_3"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_3"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the ns:objB_4 element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "objB_4"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_4"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - ASSERT_EQ(reader->GetInnerXml(), "this is mixed content &EA;"); - ASSERT_EQ(reader->GetOuterXml(), - "" - "this is mixed content &EA;"); - - // Move to the element node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 3); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "b"); - ASSERT_EQ(reader->GetQualifiedName(), "b"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the text node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 4); - ASSERT_EQ(reader->GetType(), XML_NODE_TEXT); - ASSERT_EQ(reader->GetLocalName(), "#text"); - ASSERT_EQ(reader->GetQualifiedName(), "#text"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), "this is"); - - // Move to the element node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 3); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "b"); - ASSERT_EQ(reader->GetQualifiedName(), "b"); - - // Move to the text node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 3); - ASSERT_EQ(reader->GetType(), XML_NODE_TEXT); - ASSERT_EQ(reader->GetLocalName(), "#text"); - ASSERT_EQ(reader->GetQualifiedName(), "#text"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), " mixed content "); - - // Move to the EA entity reference node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 3); - ASSERT_EQ(reader->GetType(), XML_NODE_ENTITY_REFERENCE); - ASSERT_EQ(reader->GetLocalName(), "EA"); - ASSERT_EQ(reader->GetQualifiedName(), "EA"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_EQ(reader->GetValue(), "EA Value"); - - // Move to the ns:objB_4 element ending node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "objB_4"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB_4"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the ns:objB element ending node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "objB"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objB"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the whitespace node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to the ns:objC element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "objC"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objC"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_TRUE(reader->IsEmptyElement()); - ASSERT_TRUE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - ASSERT_EQ(reader->GetAttributeCount(), (size_t)2); - ASSERT_EQ(reader->GetAttribute(0), "value C1"); - ASSERT_EQ(reader->GetAttribute("ns:attr1"), "value C1"); - ASSERT_EQ(reader->GetAttribute("attr1", "http://www.example.org/ns"), - "value C1"); - ASSERT_EQ(reader->GetAttribute(1), "value C2"); - ASSERT_EQ(reader->GetAttribute("ns:attr2"), "value C2"); - ASSERT_EQ(reader->GetAttribute("attr2", "http://www.example.org/ns"), - "value C2"); - - // Move to the ns:attr1 attribute. - ASSERT_TRUE(reader->MoveToFirstAttribute()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); - ASSERT_EQ(reader->GetLocalName(), "attr1"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:attr1"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_EQ(reader->GetValue(), "value C1"); - - // Move to the ns:attr2 attribute. - ASSERT_TRUE(reader->MoveToNextAttribute()); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); - ASSERT_EQ(reader->GetLocalName(), "attr2"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:attr2"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_EQ(reader->GetValue(), "value C2"); - - // No more attributes. - ASSERT_FALSE(reader->MoveToNextAttribute()); - - // Return to the ns:objC element start node. - ASSERT_TRUE(reader->MoveToCarryingElement()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objC"); - - // Move to the ns:attr1 attribute. - ASSERT_TRUE(reader->MoveToAttribute(0)); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); - ASSERT_EQ(reader->GetLocalName(), "attr1"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:attr1"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_EQ(reader->GetValue(), "value C1"); - - // Return to the ns:objC element start node. - ASSERT_TRUE(reader->MoveToCarryingElement()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objC"); - - // Move to the ns:attr2 attribute. - ASSERT_TRUE(reader->MoveToAttribute("ns:attr2")); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); - ASSERT_EQ(reader->GetLocalName(), "attr2"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:attr2"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_EQ(reader->GetValue(), "value C2"); - - // Move to the ns:attr1 attribute without returning to the ns:objC element. - ASSERT_TRUE(reader->MoveToAttribute("attr1", "http://www.example.org/ns")); - ASSERT_EQ(reader->GetDepth(), 2); - ASSERT_EQ(reader->GetType(), XML_NODE_ATTRIBUTE); - ASSERT_EQ(reader->GetLocalName(), "attr1"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:attr1"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_TRUE(reader->HasValue()); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_EQ(reader->GetValue(), "value C1"); - - // Move to the ns:objD element start node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_START); - ASSERT_EQ(reader->GetLocalName(), "objD"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objD"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the ns:objD element end node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 1); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "objD"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:objD"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_FALSE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - - // Move to the whitespace node without returning to the ns:objC element. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetType(), XML_NODE_WHITESPACE); - - // Move to ns:obj element ending node. - ASSERT_TRUE(reader->MoveToNextNode()); - ASSERT_EQ(reader->GetDepth(), 0); - ASSERT_EQ(reader->GetType(), XML_NODE_ELEMENT_END); - ASSERT_EQ(reader->GetLocalName(), "obj"); - ASSERT_EQ(reader->GetPrefix(), "ns"); - ASSERT_EQ(reader->GetQualifiedName(), "ns:obj"); - ASSERT_EQ(reader->GetNamespaceURI(), "http://www.example.org/ns"); - ASSERT_FALSE(reader->IsEmptyElement()); - ASSERT_TRUE(reader->HasAttributes()); - ASSERT_FALSE(reader->HasValue()); - // Strangely, the end node will report if the starting node has attributes - // but will not provide access to them. - ASSERT_TRUE(reader->HasAttributes()); - ASSERT_EQ(reader->GetAttributeCount(), (size_t)0); - - // And we're done. - ASSERT_FALSE(reader->MoveToNextNode()); - - ASSERT_TRUE(reader->Close()); -} - -// Test XML read error handling. -TEST(XmlReaderTest, ReadError) { - char test_str[] = - "\n" - "\n"; - - // Create the stream reader. - CefRefPtr stream( - CefStreamReader::CreateForData(test_str, sizeof(test_str) - 1)); - ASSERT_TRUE(stream.get() != NULL); - - // Create the XML reader. - CefRefPtr reader( - CefXmlReader::Create(stream, XML_ENCODING_NONE, - "http://www.example.org/example.xml")); - ASSERT_TRUE(reader.get() != NULL); - - // Move to the processing instruction node and generate parser error. - ASSERT_FALSE(reader->MoveToNextNode()); - ASSERT_TRUE(reader->HasError()); -} - -// Test XmlObject load behavior. -TEST(XmlReaderTest, ObjectLoad) { - // Create the stream reader. - CefRefPtr stream( - CefStreamReader::CreateForData(g_test_xml, sizeof(g_test_xml) - 1)); - ASSERT_TRUE(stream.get() != NULL); - - // Create the XML reader. - CefRefPtr object(new CefXmlObject("object")); - ASSERT_TRUE(object->Load(stream, XML_ENCODING_NONE, - "http://www.example.org/example.xml", NULL)); - - ASSERT_FALSE(object->HasAttributes()); - ASSERT_TRUE(object->HasChildren()); - ASSERT_EQ(object->GetChildCount(), (size_t)1); - - CefRefPtr obj(object->FindChild("ns:obj")); - ASSERT_TRUE(obj.get()); - ASSERT_TRUE(obj->HasChildren()); - ASSERT_EQ(obj->GetChildCount(), (size_t)4); - - CefRefPtr obj_child(obj->FindChild("ns:objC")); - ASSERT_TRUE(obj_child.get()); - ASSERT_EQ(obj_child->GetName(), "ns:objC"); - ASSERT_FALSE(obj_child->HasChildren()); - ASSERT_FALSE(obj_child->HasValue()); - ASSERT_TRUE(obj_child->HasAttributes()); - - CefXmlObject::ObjectVector obj_children; - ASSERT_EQ(obj->GetChildren(obj_children), (size_t)4); - ASSERT_EQ(obj_children.size(), (size_t)4); - - CefXmlObject::ObjectVector::const_iterator it = obj_children.begin(); - for (int ct = 0; it != obj_children.end(); ++it, ++ct) { - obj_child = *it; - ASSERT_TRUE(obj_child.get()); - if (ct == 0) { - // ns:objA - ASSERT_EQ(obj_child->GetName(), "ns:objA"); - ASSERT_FALSE(obj_child->HasChildren()); - ASSERT_TRUE(obj_child->HasValue()); - ASSERT_FALSE(obj_child->HasAttributes()); - ASSERT_EQ(obj_child->GetValue(), "value A"); - } else if (ct == 1) { - // ns:objB - ASSERT_EQ(obj_child->GetName(), "ns:objB"); - ASSERT_TRUE(obj_child->HasChildren()); - ASSERT_FALSE(obj_child->HasValue()); - ASSERT_FALSE(obj_child->HasAttributes()); - ASSERT_EQ(obj_child->GetChildCount(), (size_t)4); - obj_child = obj_child->FindChild("ns:objB_4"); - ASSERT_TRUE(obj_child.get()); - ASSERT_TRUE(obj_child->HasValue()); - ASSERT_EQ(obj_child->GetValue(), - "this is mixed content EA Value"); - } else if (ct == 2) { - // ns:objC - ASSERT_EQ(obj_child->GetName(), "ns:objC"); - ASSERT_FALSE(obj_child->HasChildren()); - ASSERT_FALSE(obj_child->HasValue()); - ASSERT_TRUE(obj_child->HasAttributes()); - - CefXmlObject::AttributeMap attribs; - ASSERT_EQ(obj_child->GetAttributes(attribs), (size_t)2); - ASSERT_EQ(attribs.size(), (size_t)2); - ASSERT_EQ(attribs["ns:attr1"], "value C1"); - ASSERT_EQ(attribs["ns:attr2"], "value C2"); - - ASSERT_EQ(obj_child->GetAttributeCount(), (size_t)2); - ASSERT_TRUE(obj_child->HasAttribute("ns:attr1")); - ASSERT_EQ(obj_child->GetAttributeValue("ns:attr1"), "value C1"); - ASSERT_TRUE(obj_child->HasAttribute("ns:attr2")); - ASSERT_EQ(obj_child->GetAttributeValue("ns:attr2"), "value C2"); - } else if (ct == 3) { - // ns:objD - ASSERT_EQ(obj_child->GetName(), "ns:objD"); - ASSERT_FALSE(obj_child->HasChildren()); - ASSERT_FALSE(obj_child->HasValue()); - ASSERT_FALSE(obj_child->HasAttributes()); - } - } -} - -// Test XmlObject load error handling behavior. -TEST(XmlReaderTest, ObjectLoadError) { - // Test start/end tag mismatch error. - { - char error_xml[] = "\n\n\n"; - - // Create the stream reader. - CefRefPtr stream( - CefStreamReader::CreateForData(error_xml, sizeof(error_xml) - 1)); - ASSERT_TRUE(stream.get() != NULL); - - CefString error_str; - - // Create the XML reader. - CefRefPtr object(new CefXmlObject("object")); - ASSERT_FALSE(object->Load(stream, XML_ENCODING_NONE, - "http://www.example.org/example.xml", &error_str)); - ASSERT_EQ(error_str, - "Opening and ending tag mismatch: foo line 2 and obj, line 3"); - } - - // Test value following child error. - { - char error_xml[] = "\n\ndisallowed value\n"; - - // Create the stream reader. - CefRefPtr stream( - CefStreamReader::CreateForData(error_xml, sizeof(error_xml) - 1)); - ASSERT_TRUE(stream.get() != NULL); - - CefString error_str; - - // Create the XML reader. - CefRefPtr object(new CefXmlObject("object")); - ASSERT_FALSE(object->Load(stream, XML_ENCODING_NONE, - "http://www.example.org/example.xml", &error_str)); - ASSERT_EQ(error_str, - "Value following child element, line 4"); - } -} diff --git a/tests/unittests/zip_reader_unittest.cc b/tests/unittests/zip_reader_unittest.cc deleted file mode 100644 index 41f83fdde..000000000 --- a/tests/unittests/zip_reader_unittest.cc +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#include "include/cef_stream.h" -#include "include/cef_zip_reader.h" -#include "include/wrapper/cef_zip_archive.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - - unsigned char g_test_zip[] = { - 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x7f, - 0x57, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, - 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x50, 0x4b, 0x03, 0x04, 0x0a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x7f, 0x57, 0x3d, 0xf8, 0x47, 0x0c, - 0xc6, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, - 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, - 0x65, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x74, 0x78, 0x74, - 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, 0x20, - 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x50, 0x4b, 0x03, 0x04, 0x0a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x7f, 0x57, 0x3d, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, - 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, - 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x50, - 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x7f, 0x57, - 0x3d, 0x43, 0xe3, 0x11, 0x5f, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, - 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, - 0x20, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x2e, 0x74, - 0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, - 0x66, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x41, 0x2e, 0x50, 0x4b, - 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x7f, 0x57, 0x3d, - 0x80, 0xb0, 0x3c, 0x74, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, - 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, - 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x62, 0x2e, 0x74, 0x78, - 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, - 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x42, 0x2e, 0x50, 0x4b, 0x03, - 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7f, 0x57, 0x3d, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, - 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, - 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, 0x2f, 0x50, - 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7f, 0x57, - 0x3d, 0x15, 0xed, 0x04, 0x2c, 0x15, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, - 0x00, 0x2c, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, - 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, - 0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, - 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x31, 0x2e, 0x74, 0x78, - 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, - 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x41, 0x31, 0x2e, 0x50, 0x4b, - 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x7f, 0x57, 0x3d, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, - 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, - 0x32, 0x2f, 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x80, 0x57, 0x3d, 0x1a, 0x5d, 0x57, 0x5d, 0x14, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, - 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, - 0x64, 0x65, 0x72, 0x20, 0x32, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x32, - 0x61, 0x2e, 0x74, 0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x73, 0x20, 0x6f, 0x66, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x32, 0x41, - 0x2e, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x67, 0x7f, 0x57, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, - 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, - 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x7f, 0x57, 0x3d, 0xf8, 0x47, 0x0c, 0xc6, 0x13, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x74, 0x65, - 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, - 0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01, - 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x7f, 0x57, - 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, - 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, - 0x65, 0x72, 0x20, 0x31, 0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x7f, 0x57, 0x3d, 0x43, 0xe3, 0x11, - 0x5f, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xa7, - 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, - 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, - 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x2e, 0x74, 0x78, 0x74, - 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x78, 0x7f, 0x57, 0x3d, 0x80, 0xb0, 0x3c, 0x74, 0x14, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0x74, 0x65, - 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, - 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, - 0x20, 0x31, 0x62, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01, 0x02, 0x14, - 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7f, 0x57, 0x3d, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x4d, 0x01, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, - 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, - 0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, - 0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7c, 0x7f, 0x57, 0x3d, 0x15, 0xed, 0x04, 0x2c, 0x15, 0x00, 0x00, - 0x00, 0x15, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x8b, 0x01, 0x00, 0x00, 0x74, - 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, - 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c, - 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, - 0x31, 0x61, 0x31, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01, 0x02, 0x14, - 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x7f, 0x57, 0x3d, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, - 0x00, 0xea, 0x01, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, - 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, - 0x20, 0x32, 0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, 0x80, 0x57, 0x3d, 0x1a, 0x5d, 0x57, 0x5d, 0x14, - 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1e, 0x02, 0x00, - 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, - 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x32, 0x2f, 0x66, - 0x69, 0x6c, 0x65, 0x20, 0x32, 0x61, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, - 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x09, 0x00, 0x9d, 0x02, - 0x00, 0x00, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - -} // namespace - -// Test Zip reading. -TEST(ZipReaderTest, Read) { - // Create the stream reader. - CefRefPtr stream( - CefStreamReader::CreateForData(g_test_zip, sizeof(g_test_zip) - 1)); - ASSERT_TRUE(stream.get() != NULL); - - // Create the Zip reader. - CefRefPtr reader(CefZipReader::Create(stream)); - ASSERT_TRUE(reader.get() != NULL); - - char buff[25]; - - // Walk through the archive contents. - ASSERT_TRUE(reader->MoveToFirstFile()); - ASSERT_EQ(reader->GetFileName(), "test_archive/"); - ASSERT_EQ(reader->GetFileSize(), 0); - - ASSERT_TRUE(reader->MoveToNextFile()); - ASSERT_EQ(reader->GetFileName(), "test_archive/file 1.txt"); - ASSERT_EQ(reader->GetFileSize(), 19); - ASSERT_TRUE(reader->OpenFile("")); - ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 19); - ASSERT_TRUE(!strncmp(buff, "Contents of file 1.", 19)); - - ASSERT_TRUE(reader->MoveToNextFile()); - ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/"); - ASSERT_EQ(reader->GetFileSize(), 0); - - ASSERT_TRUE(reader->MoveToNextFile()); - ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1a.txt"); - ASSERT_EQ(reader->GetFileSize(), 20); - ASSERT_TRUE(reader->OpenFile("")); - ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20); - ASSERT_TRUE(reader->CloseFile()); - ASSERT_TRUE(!strncmp(buff, "Contents of file 1A.", 20)); - - ASSERT_TRUE(reader->MoveToNextFile()); - ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1b.txt"); - ASSERT_EQ(reader->GetFileSize(), 20); - ASSERT_TRUE(reader->OpenFile("")); - ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20); - ASSERT_TRUE(reader->CloseFile()); - ASSERT_TRUE(!strncmp(buff, "Contents of file 1B.", 20)); - - ASSERT_TRUE(reader->MoveToNextFile()); - ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/folder 1a/"); - ASSERT_EQ(reader->GetFileSize(), 0); - - ASSERT_TRUE(reader->MoveToNextFile()); - ASSERT_EQ(reader->GetFileName(), - "test_archive/folder 1/folder 1a/file 1a1.txt"); - ASSERT_EQ(reader->GetFileSize(), 21); - ASSERT_TRUE(reader->OpenFile("")); - ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 21); - ASSERT_TRUE(reader->CloseFile()); - ASSERT_TRUE(!strncmp(buff, "Contents of file 1A1.", 21)); - - ASSERT_TRUE(reader->MoveToNextFile()); - ASSERT_EQ(reader->GetFileName(), "test_archive/folder 2/"); - ASSERT_EQ(reader->GetFileSize(), 0); - - ASSERT_TRUE(reader->MoveToNextFile()); - ASSERT_EQ(reader->GetFileName(), "test_archive/folder 2/file 2a.txt"); - ASSERT_EQ(reader->GetFileSize(), 20); - ASSERT_TRUE(reader->OpenFile("")); - ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20); - ASSERT_TRUE(reader->CloseFile()); - ASSERT_TRUE(!strncmp(buff, "Contents of file 2A.", 20)); - - ASSERT_FALSE(reader->MoveToNextFile()); - - // Try seeking a particular file - ASSERT_TRUE(reader->MoveToFile("TEST_ARCHIVE/FOLDER 1/FILE 1B.TXT", false)); - ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1b.txt"); - ASSERT_EQ(reader->GetFileSize(), 20); - ASSERT_TRUE(reader->OpenFile("")); - ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20); - ASSERT_TRUE(reader->CloseFile()); - ASSERT_TRUE(!strncmp(buff, "Contents of file 1B.", 20)); - - ASSERT_TRUE(reader->MoveToFile("test_archive/folder 1/file 1b.txt", true)); - ASSERT_FALSE(reader->MoveToFile("test_archive/folder 1/FILE 1B.txt", true)); - - ASSERT_TRUE(reader->Close()); -} - -// Test CefZipArchive object. -TEST(ZipReaderTest, ReadArchive) { - // Create the stream reader. - CefRefPtr stream( - CefStreamReader::CreateForData(g_test_zip, sizeof(g_test_zip) - 1)); - ASSERT_TRUE(stream.get() != NULL); - - // Create the Zip archive object. - CefRefPtr archive(new CefZipArchive()); - - ASSERT_EQ(archive->Load(stream, false), (size_t)5); - - ASSERT_TRUE(archive->HasFile("test_archive/file 1.txt")); - ASSERT_TRUE(archive->HasFile("test_archive/folder 1/file 1a.txt")); - ASSERT_TRUE(archive->HasFile("test_archive/FOLDER 1/file 1b.txt")); - ASSERT_TRUE(archive->HasFile("test_archive/folder 1/folder 1a/file 1a1.txt")); - ASSERT_TRUE(archive->HasFile("test_archive/folder 2/file 2a.txt")); - - // Test content retrieval. - CefRefPtr file; - file = archive->GetFile("test_archive/folder 2/file 2a.txt"); - ASSERT_TRUE(file.get()); - - ASSERT_EQ(file->GetDataSize(), (size_t)20); - ASSERT_TRUE(!strncmp(reinterpret_cast(file->GetData()), - "Contents of file 2A.", 20)); - - // Test stream reading. - CefRefPtr reader(file->GetStreamReader()); - ASSERT_TRUE(reader.get()); - - char buff[8]; - ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)8); - ASSERT_TRUE(!strncmp(buff, "Contents", 8)); - ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)8); - ASSERT_TRUE(!strncmp(buff, " of file", 8)); - ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)4); - ASSERT_TRUE(!strncmp(buff, " 2A.", 4)); - ASSERT_TRUE(reader->Eof()); -}