Skip to content

Commit

Permalink
Rename package to testcafe-browser-tools (closes #95) (#96)
Browse files Browse the repository at this point in the history
* Rename package to testcafe-browser-tools (closes #95)

* Use major version number

* Refactor native modules

* Fix stash error
  • Loading branch information
AndreyBelym authored and georgiy-abbasov committed Aug 18, 2016
1 parent bf05eed commit 67588d7
Show file tree
Hide file tree
Showing 27 changed files with 61 additions and 62 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# testcafe-browser-natives
# testcafe-browser-tools

[![Build Status](https://travis-ci.org/DevExpress/testcafe-browser-natives.svg)](https://travis-ci.org/DevExpress/testcafe-browser-natives)
[![Build Status](https://travis-ci.org/DevExpress/testcafe-browser-tools.svg)](https://travis-ci.org/DevExpress/testcafe-browser-tools)

TestСafe Browser Natives is a TestCafe library for performing platform-dependent actions on browser windows.
Working with browsers is specific for each operating system and requires native code to deal with. Since TestCafe supports painless and simple installation, this package encapsulates pre-built binaries for all supported platforms and JS-wrappers around them. This helps end-users avoid running *post-npm-install* build actions.
TestСafe Browser Tools is an utility library for performing platform-dependent actions on browser windows.
Working with browsers is specific for each operating system and requires native code to deal with. In order to provide painless and simple installation, this package encapsulates pre-built binaries for all supported platforms and JS-wrappers around them. This helps end-users avoid running *post-npm-install* build actions.

#Build Process
To build native binaries from source files, execute the gulp task corresponding to your operating system:
Expand All @@ -19,7 +19,7 @@ The *bin* directory contains pre-built native binaries. Consider using them if y
#Install

```
$ npm install testcafe-browser-natives
$ npm install testcafe-browser-tools
```
#API Reference

Expand Down
Binary file modified bin/win/close.exe
Binary file not shown.
Binary file modified bin/win/find-window.exe
Binary file not shown.
Binary file modified bin/win/generate-thumbnail.exe
Binary file not shown.
Binary file modified bin/win/get-window-size.exe
Binary file not shown.
Binary file modified bin/win/maximize.exe
Binary file not shown.
Binary file modified bin/win/resize.exe
Binary file not shown.
Binary file modified bin/win/screenshot.exe
Binary file not shown.
Binary file modified bin/win/utils.dll
Binary file not shown.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "testcafe-browser-natives",
"version": "0.16.1",
"description": "A library used by TestCafe for performing platform-dependent actions on browsers.",
"homepage": "https://github.com/DevExpress/testcafe-browser-natives",
"bugs": "https://github.com/DevExpress/testcafe-browser-natives/issues",
"name": "testcafe-browser-tools",
"version": "1.0.0",
"description": "An utility library for performing platform-dependent actions on browsers.",
"homepage": "https://github.com/DevExpress/testcafe-browser-tools",
"bugs": "https://github.com/DevExpress/testcafe-browser-tools/issues",
"license": "MIT",
"author": "Developer Express Inc.",
"repository": {
"type": "git",
"url": "https://github.com/DevExpress/testcafe-browser-natives.git"
"url": "https://github.com/DevExpress/testcafe-browser-tools.git"
},
"engines": {
"node": ">= 0.10"
Expand Down
6 changes: 3 additions & 3 deletions src/natives/close/win/Close.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Text;
using System.Runtime.InteropServices;

namespace BrowserNatives {
namespace BrowserTools {
class Close {
//Const
const UInt32 WM_CLOSE = 0x10;
Expand All @@ -25,7 +25,7 @@ static void Main (string[] args) {

string hWndStr = args[0];

CloseWindow((IntPtr)int.Parse(hWndStr));
CloseWindow((IntPtr)int.Parse(hWndStr));
}
}
}
}
6 changes: 3 additions & 3 deletions src/natives/close/win/close.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{04A6CB59-0DDB-4BE7-B7A2-DCD2B0023DC3}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrowserNatives</RootNamespace>
<RootNamespace>BrowserTools</RootNamespace>
<AssemblyName>close</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand All @@ -32,7 +32,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BrowserNatives.Close</StartupObject>
<StartupObject>BrowserTools.Close</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -51,4 +51,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
4 changes: 2 additions & 2 deletions src/natives/find-window/win/FindWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Diagnostics;
using System.Threading;

namespace BrowserNatives {
namespace BrowserTools {
class FindWindow {
//Consts
const string IE_MAIN_WINDOW_CLASS_NAME = "IEFrame";
Expand All @@ -28,7 +28,7 @@ private static bool IsIEMainWindow (IntPtr hWnd) {
private static bool CheckWindowTitle (IntPtr hWnd, ref string windowMark) {
string title = Utils.GetWindowTitle(hWnd).ToLower();

if (!title.Contains(windowMark.ToLower()))
if (!title.Contains(windowMark.ToLower()))
return true;

uint processID = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/natives/find-window/win/find-window.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{16615D42-2D28-4B3B-9278-8F02D8EB96B9}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrowserNatives</RootNamespace>
<RootNamespace>BrowserTools</RootNamespace>
<AssemblyName>find-window</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand All @@ -33,7 +33,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BrowserNatives.FindWindow</StartupObject>
<StartupObject>BrowserTools.FindWindow</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="utils">
Expand Down Expand Up @@ -69,4 +69,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
4 changes: 2 additions & 2 deletions src/natives/generate-thumbnail/any/generate-thumbnail.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A438BDF5-3173-4045-B6D7-C14AA431BCF0}</ProjectGuid>
<RootNamespace>BrowserNatives</RootNamespace>
<RootNamespace>BrowserTools</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -75,4 +75,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion src/natives/get-window-size/win/GetWindowSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Windows.Forms;
using System.Threading;

namespace BrowserNatives {
namespace BrowserTools {
class GetWindowSize {
static void Main (string[] args) {
if (args.Length != 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/natives/get-window-size/win/get-window-size.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{7C5ABA0D-970C-4E8E-962C-A006AEE1E271}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrowserNatives</RootNamespace>
<RootNamespace>BrowserTools</RootNamespace>
<AssemblyName>get-window-size</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand All @@ -32,7 +32,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BrowserNatives.GetWindowSize</StartupObject>
<StartupObject>BrowserTools.GetWindowSize</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="utils">
Expand Down
2 changes: 1 addition & 1 deletion src/natives/maximize/win/Maximize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Threading;
using System.Text;

namespace BrowserNatives {
namespace BrowserTools {
class Maximize {
//Consts
const int SW_SHOWMAXIMIZED = 3;
Expand Down
4 changes: 2 additions & 2 deletions src/natives/maximize/win/maximize.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{A88A5114-CBC7-4730-87FB-D1512043EF7C}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrowserNatives</RootNamespace>
<RootNamespace>BrowserTools</RootNamespace>
<AssemblyName>maximize</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -48,7 +48,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BrowserNatives.Maximize</StartupObject>
<StartupObject>BrowserTools.Maximize</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="utils">
Expand Down
4 changes: 2 additions & 2 deletions src/natives/resize/win/Resize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Threading;
using System.Text;

namespace BrowserNatives {
namespace BrowserTools {
class Resize {
//Consts
const int SW_RESTORE = 9;
Expand Down Expand Up @@ -38,7 +38,7 @@ static void ResizeWindow (IntPtr hWnd, int width, int height) {
WindowInfo wi = Utils.GetWindowInfo(hWnd);

SetWindowPos(
hWnd,
hWnd,
IntPtr.Zero,
wi.rcWindow.left,
wi.rcWindow.top,
Expand Down
4 changes: 2 additions & 2 deletions src/natives/resize/win/resize.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{A88A5114-CBC7-4730-87FB-D1512043EF7C}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrowserNatives</RootNamespace>
<RootNamespace>BrowserTools</RootNamespace>
<AssemblyName>resize</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -48,7 +48,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BrowserNatives.Resize</StartupObject>
<StartupObject>BrowserTools.Resize</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="utils">
Expand Down
2 changes: 1 addition & 1 deletion src/natives/screenshot/win/Screenshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Threading;
using System.Linq;

namespace BrowserNatives {
namespace BrowserTools {
class Screenshot {
//Consts
const int GW_CHILD = 5;
Expand Down
4 changes: 2 additions & 2 deletions src/natives/screenshot/win/screenshot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{7C5ABA0D-970C-4E8E-962C-A006AEE1E271}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrowserNatives</RootNamespace>
<RootNamespace>BrowserTools</RootNamespace>
<AssemblyName>screenshot</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand All @@ -32,7 +32,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BrowserNatives.Screenshot</StartupObject>
<StartupObject>BrowserTools.Screenshot</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="utils">
Expand Down
3 changes: 1 addition & 2 deletions src/natives/utils/win/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
using System.Runtime.InteropServices;
using System.Threading;

namespace BrowserNatives
{
namespace BrowserTools {
//Win32 Type Definitions
[StructLayout(LayoutKind.Sequential)]
public struct Rect {
Expand Down
6 changes: 3 additions & 3 deletions src/natives/utils/win/utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{E75454E4-2FCE-4032-8C26-AACE8E8048B0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrowserNatives</RootNamespace>
<RootNamespace>BrowserTools</RootNamespace>
<AssemblyName>utils</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -44,11 +44,11 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
30 changes: 15 additions & 15 deletions test/playground/routes.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var path = require('path');
var viewports = require('viewportsizes');
var Promise = require('pinkie');
var browserNatives = require('../../lib/index');
var toAbsPath = require('read-file-relative').toAbsPath;
var path = require('path');
var viewports = require('viewportsizes');
var Promise = require('pinkie');
var browserTools = require('../../lib/index');
var toAbsPath = require('read-file-relative').toAbsPath;

const WINDOW_NORMALIZING_DELAY = 1000;

Expand Down Expand Up @@ -62,7 +62,7 @@ function getRequestedSize (params) {
if (params.paramsType === 'width-height')
return { width: Number(params.width), height: Number(params.height) };

var deviceSize = browserNatives.getViewportSize(params.deviceName);
var deviceSize = browserTools.getViewportSize(params.deviceName);

return params.orientation === 'portrait' ?
{ width: deviceSize.portraitWidth, height: deviceSize.landscapeWidth } :
Expand All @@ -80,7 +80,7 @@ exports.init = function (appPort) {
port = appPort;
deviceNames = getDeviceNames();

return browserNatives
return browserTools
.getInstallations()
.then(function (res) {
installations = res;
Expand Down Expand Up @@ -113,7 +113,7 @@ exports.open = function (req, res) {
// sometimes the browser sends client size information before the 'open' function resolves.
browsers.push(browser);

return browserNatives
return browserTools
.open(browser.browserInfo, browser.pageUrl)
.then(function () {
res.locals = { id: browser.id, name: browser.name, deviceNames: deviceNames };
Expand All @@ -127,7 +127,7 @@ exports.open = function (req, res) {

exports.close = function (req, res) {
function close (browser) {
return browserNatives
return browserTools
.close(browser.pageUrl)
.then(function () {
browsers = browsers.filter(function (item) {
Expand All @@ -146,7 +146,7 @@ exports.resize = function (req, res) {
var requestedSize = getRequestedSize(req.body);

function resizeWindow () {
return browserNatives.resize(
return browserTools.resize(
browser.pageUrl,
browser.clientAreaSize.width,
browser.clientAreaSize.height,
Expand All @@ -156,8 +156,8 @@ exports.resize = function (req, res) {
}

// NOTE: We must resize the window twice if it is maximized.
// https://github.com/DevExpress/testcafe-browser-natives/issues/71
return browserNatives
// https://github.com/DevExpress/testcafe-browser-tools/issues/71
return browserTools
.isMaximized(browser.pageUrl)
.then(function (maximized) {
if (!maximized)
Expand Down Expand Up @@ -187,7 +187,7 @@ exports.resize = function (req, res) {

exports.maximize = function (req, res) {
function maximize (browser) {
return browserNatives
return browserTools
.maximize(browser.pageUrl)
.then(function () {
res.set('content-type', 'text/plain').end();
Expand Down Expand Up @@ -223,10 +223,10 @@ exports.takeScreenshot = function (req, res) {
thumbnailPath = path.join(screenshotDirPath, 'thumbnails', screenshotFilename);
}

return browserNatives
return browserTools
.screenshot(browser.pageUrl, screenshotPath)
.then(function () {
return browserNatives.generateThumbnail(screenshotPath, thumbnailPath);
return browserTools.generateThumbnail(screenshotPath, thumbnailPath);
})
.then(function () {
if (!cachedScreenshots.length) {
Expand Down
Loading

0 comments on commit 67588d7

Please sign in to comment.