Permalink
Browse files

Merge remote-tracking branch 'JamesMGreene/ExposeProcessId'

  • Loading branch information...
2 parents eadb03a + 2803057 commit 7b84e43a10cea3655020d9e013f2ee0e8a5f0eb0 @ariya committed Nov 8, 2012
Showing with 28 additions and 0 deletions.
  1. +8 −0 src/system.cpp
  2. +4 −0 src/system.h
  3. +16 −0 test/system-spec.js
View
@@ -2,6 +2,7 @@
This file is part of the PhantomJS project from Ofi Labs.
Copyright (C) 2012 execjosh, http://execjosh.blogspot.com
+ Copyright (C) 2012 James M. Greene <james.m.greene@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -29,6 +30,7 @@
#include "system.h"
+#include <QApplication>
#include <QSslSocket>
#include <QSysInfo>
#include <QVariantMap>
@@ -120,6 +122,11 @@ System::System(QObject *parent) :
#endif
}
+qint64 System::pid() const
+{
+ return QApplication::applicationPid();
+}
+
void System::setArgs(const QStringList &args)
{
m_args = args;
@@ -147,6 +154,7 @@ bool System::isSSLSupported() const
void System::initCompletions()
{
+ addCompletion("pid");
addCompletion("args");
addCompletion("env");
addCompletion("platform");
View
@@ -2,6 +2,7 @@
This file is part of the PhantomJS project from Ofi Labs.
Copyright (C) 2012 execjosh, http://execjosh.blogspot.com
+ Copyright (C) 2012 James M. Greene <james.m.greene@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,6 +43,7 @@
class System : public REPLCompletable
{
Q_OBJECT
+ Q_PROPERTY(qint64 pid READ pid)
Q_PROPERTY(QStringList args READ args)
Q_PROPERTY(QVariant env READ env)
Q_PROPERTY(QVariant os READ os)
@@ -50,6 +52,8 @@ class System : public REPLCompletable
public:
explicit System(QObject *parent = 0);
+ qint64 pid() const;
+
void setArgs(const QStringList& args);
QStringList args() const;
View
@@ -6,6 +6,22 @@ describe("System object", function() {
expect(system).toNotEqual(null);
});
+ it("should have pid property", function() {
+ expect(system.hasOwnProperty('pid')).toBeTruthy();
+ });
+
+ it("should have pid as a number", function() {
+ expect(typeof system.pid).toEqual('number');
+ });
+
+ it("should have pid that is an integer", function() {
+ expect(system.pid).toMatch(/^\d+$/);
+ });
+
+ it("should have pid greater than 0", function() {
+ expect(system.pid).toBeGreaterThan(0);
+ });
+
it("should have platform as string", function() {
expect(typeof system.platform).toEqual('string');
});

0 comments on commit 7b84e43

Please sign in to comment.