Skip to content

Commit

Permalink
Merge pull request #140 from trikset/wpa
Browse files Browse the repository at this point in the history
Wpa
  • Loading branch information
yurii-litvinov committed Dec 9, 2015
2 parents 9d8dc5d + eb6b9e5 commit 1cc90f7
Show file tree
Hide file tree
Showing 31 changed files with 827 additions and 543 deletions.
4 changes: 3 additions & 1 deletion tests/tests.pro
Expand Up @@ -15,12 +15,14 @@
TEMPLATE = subdirs

SUBDIRS = \
minimalCppApp \
selftest \
thirdparty \
trikKernelTests \
trikScriptRunnerTests \
minimalCppApp \

thirdparty.file = thirdparty/gmock-1.6.0/gmock.pro

trikKernelTests.depends = thirdparty
trikScriptRunnerTests.depends = thirdparty
selftest.depends = thirdparty
76 changes: 76 additions & 0 deletions tests/trikKernelTests/synchronizedVarTest.cpp
@@ -0,0 +1,76 @@
/* Copyright 2015 CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */

#include "synchronizedVarTest.h"

#include <trikKernel/synchronizedVar.h>

#include <QtCore/QList>

using namespace tests;
using namespace trikKernel;

struct Point
{
int x;
int y;
};

TEST_F(SynchronizedVarTest, structTest)
{
SynchronizedVar<Point> var;
var->x = 10;
var->y = 10;
var.sync();
var->x = 20;
var->y = 20;
EXPECT_EQ(10, var.get().x);
var.sync();
EXPECT_EQ(20, var.get().x);
var->x = 30;
var->y = 30;
EXPECT_EQ(20, var.get().x);
}

TEST_F(SynchronizedVarTest, listTest)
{
SynchronizedVar<QList<Point>> list;
EXPECT_TRUE(list.get().isEmpty());

const Point point{10, 10};
list->append(point);

EXPECT_TRUE(list.get().isEmpty());

list.sync();

ASSERT_FALSE(list.get().isEmpty());
EXPECT_EQ(10, list.get().at(0).x);
}

TEST_F(SynchronizedVarTest, resetTest)
{
SynchronizedVar<QList<Point>> list;
list->append({10, 10});

list.sync();

EXPECT_FALSE(list.get().isEmpty());

list.reset();

EXPECT_TRUE(list.get().isEmpty());
list.sync();
EXPECT_TRUE(list.get().isEmpty());
}
26 changes: 26 additions & 0 deletions tests/trikKernelTests/synchronizedVarTest.h
@@ -0,0 +1,26 @@
/* Copyright 2015 CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */

#pragma once

#include <gtest/gtest.h>

namespace tests {

/// Test fixture for SynchronizedVar class.
class SynchronizedVarTest : public testing::Test
{
};

}
26 changes: 26 additions & 0 deletions tests/trikKernelTests/trikKernelTests.pro
@@ -0,0 +1,26 @@
# Copyright 2014 - 2015 CyberTech Labs Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include(../../global.pri)

include(../common.pri)

HEADERS += \
$$PWD/synchronizedVarTest.h \

SOURCES += \
$$PWD/synchronizedVarTest.cpp \

implementationIncludes(trikKernel)
links(trikKernel)
45 changes: 25 additions & 20 deletions translations/fr/trikGui_fr.ts
Expand Up @@ -50,25 +50,25 @@
<context>
<name>trikGui::Controller</name>
<message>
<location filename="../../trikGui/controller.cpp" line="155"/>
<location filename="../../trikGui/controller.cpp" line="165"/>
<source>direct command</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>trikGui::FileManagerWidget</name>
<message>
<location filename="../../trikGui/fileManagerWidget.cpp" line="94"/>
<location filename="../../trikGui/fileManagerWidget.cpp" line="101"/>
<source>File Manager</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/fileManagerWidget.cpp" line="118"/>
<location filename="../../trikGui/fileManagerWidget.cpp" line="125"/>
<source>Confirm deletion</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/fileManagerWidget.cpp" line="119"/>
<location filename="../../trikGui/fileManagerWidget.cpp" line="126"/>
<source>Are you sure you want to delete file?</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -216,12 +216,12 @@
<context>
<name>trikGui::StartWidget</name>
<message>
<location filename="../../trikGui/startWidget.cpp" line="50"/>
<location filename="../../trikGui/startWidget.cpp" line="49"/>
<source>TRIK</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/startWidget.cpp" line="55"/>
<location filename="../../trikGui/startWidget.cpp" line="54"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -318,52 +318,57 @@
<context>
<name>trikGui::WiFiClientWidget</name>
<message>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="61"/>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="56"/>
<source>IP:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="64"/>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="59"/>
<source>Name:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="69"/>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="64"/>
<source>Available networks:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="154"/>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="169"/>
<source>connecting...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="159"/>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="174"/>
<source>no connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiClientWidget.cpp" line="179"/>
<source>error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>trikGui::WiFiInitWidget</name>
<message>
<location filename="../../trikGui/wiFiInitWidget.cpp" line="31"/>
<location filename="../../trikGui/wiFiInitWidget.cpp" line="30"/>
<source>Network initialization
in process</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiInitWidget.cpp" line="33"/>
<location filename="../../trikGui/wiFiInitWidget.cpp" line="32"/>
<source>Please wait</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiInitWidget.cpp" line="34"/>
<location filename="../../trikGui/wiFiInitWidget.cpp" line="33"/>
<source>Press Escape
for break</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiInitWidget.cpp" line="115"/>
<location filename="../../trikGui/wiFiInitWidget.cpp" line="114"/>
<source>Network initialization
failed</source>
<translation type="unfinished"></translation>
Expand All @@ -372,23 +377,23 @@ failed</source>
<context>
<name>trikGui::WiFiModeWidget</name>
<message>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="35"/>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="32"/>
<source>Choose mode:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="37"/>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="64"/>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="34"/>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="61"/>
<source>Wi-Fi client</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="38"/>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="35"/>
<source>Wi-Fi access point</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="52"/>
<location filename="../../trikGui/wiFiModeWidget.cpp" line="49"/>
<source>Network Config</source>
<translation type="unfinished"></translation>
</message>
Expand Down
Binary file modified translations/ru/trikGui_ru.qm
Binary file not shown.
6 changes: 5 additions & 1 deletion translations/ru/trikGui_ru.ts
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="ru_RU">
<TS version="2.1" language="ru_RU">
<context>
<name>QObject</name>
<message>
Expand Down Expand Up @@ -329,6 +329,10 @@
<source>Name:</source>
<translation>Имя:</translation>
</message>
<message>
<source>error</source>
<translation>ошибка</translation>
</message>
</context>
<context>
<name>trikGui::WiFiInitWidget</name>
Expand Down
1 change: 1 addition & 0 deletions trikControl/src/vectorSensorWorker.cpp
Expand Up @@ -56,6 +56,7 @@ void VectorSensorWorker::onNewEvent(trikHal::EventFileInterface::EventType event
}
}

/// @todo: vector copying is not atomic, so we may receive evSyn right in the middle of "return mReading".
QVector<int> VectorSensorWorker::read()
{
if (mState.isReady()) {
Expand Down
2 changes: 1 addition & 1 deletion trikGui/backgroundWidget.cpp
Expand Up @@ -34,7 +34,7 @@ BackgroundWidget::BackgroundWidget(
, mWiFiIndicator(mController)
, mMailboxIndicator("://resources/mailboxConnected.png", mController.mailbox()->isConnected())
, mCommunicatorIndicator("://resources/communicatorConnected.png", mController.communicatorConnectionStatus())
, mStartWidget(mController, configPath)
, mStartWidget(mController)
, mRunningWidget(mController)
{
setWindowState(Qt::WindowFullScreen);
Expand Down
5 changes: 2 additions & 3 deletions trikGui/startWidget.cpp
Expand Up @@ -41,10 +41,9 @@ using namespace trikGui;
using trikControl::MotorInterface;
using trikControl::SensorInterface;

StartWidget::StartWidget(Controller &controller, const QString &configPath, QWidget *parent)
StartWidget::StartWidget(Controller &controller, QWidget *parent)
: MainWidget(parent)
, mController(controller)
, mConfigPath(configPath)
, mFileManagerRoot(MainWidget::FileManagerRootType::scriptsDir)
{
mTitleLabel.setText(tr("TRIK"));
Expand Down Expand Up @@ -114,7 +113,7 @@ void StartWidget::launch()
emit newWidget(fileManagerWidget);
result = fileManagerWidget.exec();
} else if (currentItemText == WiFiModeWidget::menuEntry()) {
WiFiModeWidget wiFiModeWidget(mConfigPath, mController.wiFi());
WiFiModeWidget wiFiModeWidget(mController.wiFi());
emit newWidget(wiFiModeWidget);
result = wiFiModeWidget.exec();
} else if (currentItemText == MotorsWidget::menuEntry(MotorInterface::Type::powerMotor)) {
Expand Down
3 changes: 1 addition & 2 deletions trikGui/startWidget.h
Expand Up @@ -53,7 +53,7 @@ class StartWidget : public MainWidget
/// @param controller - controller object that provides access to underlying runtime.
/// @param configPath - full path to configuration files.
/// @param parent - parent of this widget in Qt object hierarchy.
explicit StartWidget(Controller &controller, const QString &configPath, QWidget *parent = 0);
explicit StartWidget(Controller &controller, QWidget *parent = 0);

~StartWidget() override;

Expand All @@ -77,7 +77,6 @@ private slots:
QListView mMenuView;
QStandardItemModel mMenuModel;
Controller &mController;
const QString mConfigPath;
MainWidget::FileManagerRootType mFileManagerRoot; // current FilesManegerRoot

/// Stores index of item which was selected in a submenu after a last visit.
Expand Down
3 changes: 0 additions & 3 deletions trikGui/trikGui.pro
Expand Up @@ -91,10 +91,8 @@ TRANSLATIONS = \
RESOURCES = trikGui.qrc

OTHER_FILES += \
$$PWD/wpa-config.xml \
$$PWD/trikGui.sh \

copyToDestdir($$PWD/wpa-config.xml)
copyToDestdir($$PWD/trikGui.sh)

TEMPLATE = app
Expand All @@ -110,4 +108,3 @@ transitiveIncludes(trikNetwork)
links(trikKernel trikControl trikCommunicator trikScriptRunner trikWiFi trikTelemetry trikNetwork)

installs()
installAdditionalConfigs($$PWD/wpa-config.xml)

0 comments on commit 1cc90f7

Please sign in to comment.