Skip to content

Commit

Permalink
Backed out changeset 7ecdee3d9f27 (bug 772424) for causing bp-hybrid …
Browse files Browse the repository at this point in the history
…build bustages on TestWinDND.cpp. CLOSED TREE
  • Loading branch information
Iulian Moraru committed Mar 2, 2023
1 parent 59fbf15 commit ed72145
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,20 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#define MOZILLA_INTERNAL_API

// #include <windows.h>
#include <ole2.h>
#include <shlobj.h>

#include "TestHarness.h"
#include "nsArray.h"
#include "nsArrayUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsIFile.h"
#include "nsNetUtil.h"
#include "nsISupportsPrimitives.h"
#include "nsITransferable.h"

#include "nsClipboard.h"
#include "nsDataObjCollection.h"

#include "gtest/gtest.h"

// shims for conversion from cppunittest to gtest
template <size_t N>
void fail(const char (&msg)[N]) {
ADD_FAILURE() << "TEST-UNEXPECTED-FAIL | " << msg;
}
template <size_t N>
void passed(const char (&msg)[N]) {
GTEST_SUCCEED() << "TEST-PASS | " << msg;
}

nsIFile* xferFile;

nsresult CheckValidHDROP(STGMEDIUM* pSTG) {
Expand All @@ -48,17 +32,16 @@ nsresult CheckValidHDROP(STGMEDIUM* pSTG) {
return NS_ERROR_UNEXPECTED;
}

if (pDropFiles->pFiles != sizeof(DROPFILES)) {
if (pDropFiles->pFiles != sizeof(DROPFILES))
fail("DROPFILES struct has wrong size");
}

if (!pDropFiles->fWide) {
if (pDropFiles->fWide != true) {
fail("Received data is not Unicode");
return NS_ERROR_UNEXPECTED;
}
nsString s;
unsigned long offset = 0;
while (true) {
while (1) {
s = (char16_t*)((char*)pDropFiles + pDropFiles->pFiles + offset);
if (s.IsEmpty()) break;
nsresult rv;
Expand Down Expand Up @@ -177,7 +160,8 @@ nsresult GetTransferableFile(nsCOMPtr<nsITransferable>& pTransferable) {

pTransferable = do_CreateInstance("@mozilla.org/widget/transferable;1");
pTransferable->Init(nullptr);
rv = pTransferable->SetTransferData("application/x-moz-file", genericWrapper);
rv = pTransferable->SetTransferData("application/x-moz-file", genericWrapper,
0);
return rv;
}

Expand All @@ -193,7 +177,8 @@ nsresult GetTransferableText(nsCOMPtr<nsITransferable>& pTransferable) {

pTransferable = do_CreateInstance("@mozilla.org/widget/transferable;1");
pTransferable->Init(nullptr);
rv = pTransferable->SetTransferData("text/plain", genericWrapper);
rv = pTransferable->SetTransferData("text/plain", genericWrapper,
mozString.Length() * sizeof(char16_t));
return rv;
}

Expand All @@ -209,7 +194,8 @@ nsresult GetTransferableTextTwo(nsCOMPtr<nsITransferable>& pTransferable) {

pTransferable = do_CreateInstance("@mozilla.org/widget/transferable;1");
pTransferable->Init(nullptr);
rv = pTransferable->SetTransferData("text/plain", genericWrapper);
rv = pTransferable->SetTransferData("text/plain", genericWrapper,
mozString.Length() * sizeof(char16_t));
return rv;
}

Expand All @@ -225,7 +211,7 @@ nsresult GetTransferableURI(nsCOMPtr<nsITransferable>& pTransferable) {

pTransferable = do_CreateInstance("@mozilla.org/widget/transferable;1");
pTransferable->Init(nullptr);
rv = pTransferable->SetTransferData("text/x-moz-url", genericWrapper);
rv = pTransferable->SetTransferData("text/x-moz-url", genericWrapper, 0);
return rv;
}

Expand Down Expand Up @@ -681,48 +667,30 @@ nsresult Do_Test2() {
// consisting of multiple transferables that have different data types
nsresult Do_Test3() {
nsresult rv = NS_OK;
// nsresult workingrv;
nsresult workingrv;

// XXX TODO Write more advanced tests in Bug 535860
return rv;
}

nsCOMPtr<nsIFile> GetTemporaryDirectory() {
nsCOMPtr<nsIFile> tmpdir;

#define ENSURE(expr) NS_ENSURE_SUCCESS(expr, nullptr);

ENSURE(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpdir)));
MOZ_ASSERT(tmpdir);
int main(int argc, char** argv) {
ScopedXPCOM xpcom("Test Windows Drag and Drop");

ENSURE(tmpdir->AppendNative("TestWinDND"_ns));
ENSURE(tmpdir->CreateUnique(nsIFile::DIRECTORY_TYPE, 0777));

#undef ENSURE

return tmpdir;
}

TEST(TestWinDND, All)
{
nsCOMPtr<nsIFile> file = GetTemporaryDirectory();
if (!file) {
GTEST_FAIL() << "could not create temporary directory!";
return;
}
nsCOMPtr<nsIFile> file;
file = xpcom.GetProfileDirectory();
xferFile = file;

if (NS_SUCCEEDED(Do_Test1())) {
if (NS_SUCCEEDED(Do_Test1()))
passed(
"Basic Drag and Drop data type tests (single transferable) succeeded!");
}

if (NS_SUCCEEDED(Do_Test2())) {
if (NS_SUCCEEDED(Do_Test2()))
passed(
"Basic Drag and Drop data type tests (multiple transferables) "
"succeeded!");
}

// if (NS_SUCCEEDED(Do_Test3()))
// passed("Advanced Drag and Drop data type tests succeeded!");

return gFailCount;
}
16 changes: 0 additions & 16 deletions widget/windows/tests/gtest/moz.build

This file was deleted.

2 changes: 0 additions & 2 deletions widget/windows/tests/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ GeckoCppUnitTests(
linkage=None,
)

DIRS = ["gtest"]

LOCAL_INCLUDES += []

OS_LIBS += [
Expand Down

0 comments on commit ed72145

Please sign in to comment.