[Ktutorial-commits] SF.net SVN: ktutorial:[135] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-03-09 19:17:07
|
Revision: 135
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=135&view=rev
Author: danxuliu
Date: 2010-03-09 19:16:53 +0000 (Tue, 09 Mar 2010)
Log Message:
-----------
Add TutorialCustomCodeWidget and StepCustomCodeWidget widgets to edit the setup and tear down code of tutorials and steps.
Modified Paths:
--------------
trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp
trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h
trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc
trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt
trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt
Added Paths:
-----------
trunk/ktutorial/ktutorial-editor/src/view/CustomCodeWidget.ui
trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp
trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.h
trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp
trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.h
trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp
trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp
Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2010-03-09 16:14:46 UTC (rev 134)
+++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2010-03-09 19:16:53 UTC (rev 135)
@@ -28,8 +28,10 @@
#include "Step.h"
#include "Tutorial.h"
#include "view/EditionDialog.h"
+#include "view/StepCustomCodeWidget.h"
#include "view/StepDataWidget.h"
#include "view/TreeModel.h"
+#include "view/TutorialCustomCodeWidget.h"
#include "view/TutorialInformationWidget.h"
#include "view/TutorialTreeItem.h"
#include "view/TutorialTreeSelectionManager.h"
@@ -78,6 +80,20 @@
this, SLOT(setTutorialInformation()));
action = new KAction(this);
+ action->setText(i18nc("@action", "Set setup code..."));
+ action->setStatusTip(i18nc("@info:status", "Set the custom code to be "
+"executed when the tutorial starts."));
+ actionCollection()->addAction("setTutorialSetup", action);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(setTutorialSetup()));
+
+ action = new KAction(this);
+ action->setText(i18nc("@action", "Set tear down code..."));
+ action->setStatusTip(i18nc("@info:status", "Set the custom code to be "
+"executed when the tutorial finishes."));
+ actionCollection()->addAction("setTutorialTearDown", action);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(setTutorialTearDown()));
+
+ action = new KAction(this);
action->setText(i18nc("@action", "Add step..."));
action->setStatusTip(i18nc("@info:status", "Add a new step to the "
"tutorial."));
@@ -93,6 +109,23 @@
connect(action, SIGNAL(triggered(bool)), this, SLOT(setStepData()));
action = new KAction(this);
+ action->setText(i18nc("@action", "Set setup code..."));
+ action->setStatusTip(i18nc("@info:status", "Set the custom code to be "
+"executed when the tutorial passes to the currently selected step."));
+ action->setEnabled(false);
+ actionCollection()->addAction("setStepSetup", action);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(setStepSetup()));
+
+ action = new KAction(this);
+ action->setText(i18nc("@action", "Set tear down code..."));
+ action->setStatusTip(i18nc("@info:status", "Set the custom code to be "
+"executed when the tutorial changes from the currently selected step to "
+"another step."));
+ action->setEnabled(false);
+ actionCollection()->addAction("setStepTearDown", action);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(setStepTearDown()));
+
+ action = new KAction(this);
action->setText(i18nc("@action", "Remove step"));
action->setStatusTip(i18nc("@info:status", "Removes the currently selected "
"step from the tutorial."));
@@ -115,9 +148,13 @@
if (mCurrentStep) {
actionCollection()->action("setStepData")->setEnabled(true);
+ actionCollection()->action("setStepSetup")->setEnabled(true);
+ actionCollection()->action("setStepTearDown")->setEnabled(true);
actionCollection()->action("removeStep")->setEnabled(true);
} else {
actionCollection()->action("setStepData")->setEnabled(false);
+ actionCollection()->action("setStepSetup")->setEnabled(false);
+ actionCollection()->action("setStepTearDown")->setEnabled(false);
actionCollection()->action("removeStep")->setEnabled(false);
}
}
@@ -126,6 +163,16 @@
showEditionDialog(new TutorialInformationWidget(mTutorial));
}
+void KTutorialEditor::setTutorialSetup() {
+ showEditionDialog(new TutorialCustomCodeWidget(mTutorial,
+ TutorialCustomCodeWidget::Setup));
+}
+
+void KTutorialEditor::setTutorialTearDown() {
+ showEditionDialog(new TutorialCustomCodeWidget(mTutorial,
+ TutorialCustomCodeWidget::TearDown));
+}
+
void KTutorialEditor::addStep() {
Step* step = new Step();
mTutorial->addStep(step);
@@ -139,6 +186,16 @@
showEditionDialog(new StepDataWidget(mCurrentStep));
}
+void KTutorialEditor::setStepSetup() {
+ showEditionDialog(new StepCustomCodeWidget(mCurrentStep,
+ StepCustomCodeWidget::Setup));
+}
+
+void KTutorialEditor::setStepTearDown() {
+ showEditionDialog(new StepCustomCodeWidget(mCurrentStep,
+ StepCustomCodeWidget::TearDown));
+}
+
void KTutorialEditor::removeStep() {
Q_ASSERT(mCurrentStep);
Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2010-03-09 16:14:46 UTC (rev 134)
+++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2010-03-09 19:16:53 UTC (rev 135)
@@ -91,6 +91,16 @@
void setTutorialInformation();
/**
+ * Shows a TutorialCustomCodeWidget for the setup code of the tutorial.
+ */
+ void setTutorialSetup();
+
+ /**
+ * Shows a TutorialCustomCodeWidget for the tear down code of the tutorial.
+ */
+ void setTutorialTearDown();
+
+ /**
* Adds a new step to the tutorial and shows a StepDataWidget for it.
*/
void addStep();
@@ -101,6 +111,16 @@
void setStepData();
/**
+ * Shows a StepCustomCodeWidget for the setup code of the current step.
+ */
+ void setStepSetup();
+
+ /**
+ * Shows a StepCustomCodeWidget for the tear down code of the current step.
+ */
+ void setStepTearDown();
+
+ /**
* Removes the current step from the tutorial.
*/
void removeStep();
Modified: trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc 2010-03-09 16:14:46 UTC (rev 134)
+++ trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc 2010-03-09 19:16:53 UTC (rev 135)
@@ -6,11 +6,15 @@
<Menu name="editTutorials">
<Text context="@item:inmenu">Tutorial</Text>
<Action name="setTutorialInformation"/>
+ <Action name="setTutorialSetup"/>
+ <Action name="setTutorialTearDown"/>
</Menu>
<Menu name="editSteps">
<Text context="@item:inmenu">Step</Text>
<Action name="addStep"/>
<Action name="setStepData"/>
+ <Action name="setStepSetup"/>
+ <Action name="setStepTearDown"/>
<Action name="removeStep"/>
</Menu>
</Menu>
Modified: trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2010-03-09 16:14:46 UTC (rev 134)
+++ trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2010-03-09 19:16:53 UTC (rev 135)
@@ -3,18 +3,21 @@
set(ktutorial_editor_view_SRCS
EditionDialog.cpp
EditionWidget.cpp
+ StepCustomCodeWidget.cpp
StepDataWidget.cpp
StepTreeItem.cpp
TextTreeItem.cpp
TreeItem.cpp
TreeItemUtil.cpp
TreeModel.cpp
+ TutorialCustomCodeWidget.cpp
TutorialInformationWidget.cpp
TutorialTreeItem.cpp
TutorialTreeSelectionManager.cpp
)
kde4_add_ui_files(ktutorial_editor_view_SRCS
+ CustomCodeWidget.ui
StepDataWidget.ui
TutorialInformationWidget.ui
)
Added: trunk/ktutorial/ktutorial-editor/src/view/CustomCodeWidget.ui
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/CustomCodeWidget.ui (rev 0)
+++ trunk/ktutorial/ktutorial-editor/src/view/CustomCodeWidget.ui 2010-03-09 19:16:53 UTC (rev 135)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CustomCodeWidget</class>
+ <widget class="QWidget" name="CustomCodeWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string comment="@title">Set custom code</string>
+ </property>
+ <layout class="QVBoxLayout" name="CustomCodeWidgetLayout">
+ <item>
+ <widget class="QGroupBox" name="customCodeGroupBox">
+ <layout class="QVBoxLayout" name="customCodeGroupBoxLayout">
+ <item>
+ <widget class="KTextEdit" name="customCodeTextEdit"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KTextEdit</class>
+ <extends>QTextEdit</extends>
+ <header>ktextedit.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
Added: trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp (rev 0)
+++ trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp 2010-03-09 19:16:53 UTC (rev 135)
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#include "StepCustomCodeWidget.h"
+
+#include <KLocalizedString>
+
+#include "ui_CustomCodeWidget.h"
+#include "../Step.h"
+
+//public:
+
+StepCustomCodeWidget::StepCustomCodeWidget(Step* step, Type type,
+ QWidget* parent):
+ EditionWidget(parent),
+ mStep(step),
+ mType(type) {
+
+ ui = new Ui::CustomCodeWidget();
+ ui->setupUi(this);
+
+ if (type == Setup) {
+ ui->customCodeTextEdit->setText(step->customSetupCode());
+ ui->customCodeGroupBox->setTitle(i18nc("@ŧitle", "Step setup code"));
+ setWindowTitle(i18nc("@title", "Set the step setup code"));
+ setWhatsThis(i18nc("@info:whatsthis", "<para>Set the code to be "
+"executed when the tutorials passes to the step.</para>"
+"<para>The code will be written as is to the setup of the step, after the "
+"setup code generated automatically by the editor. This means that the code "
+"must be written in the same programming language the tutorial will be "
+"exported to.</para>"));
+ } else {
+ ui->customCodeTextEdit->setText(step->customTearDownCode());
+ ui->customCodeGroupBox->setTitle(i18nc("@ŧitle",
+ "Step tear down code"));
+ setWindowTitle(i18nc("@title", "Set the step tear down code"));
+ setWhatsThis(i18nc("@info:whatsthis", "<para>Set the code to be "
+"executed when the tutorial finishes.</para>"
+"<para>The code will be written as is to the tear down of the step, before the "
+"tear down code generated automatically by the editor. This means that the "
+"code must be written in the same programming language the tutorial will be "
+"exported to.</para>"));
+ }
+}
+
+StepCustomCodeWidget::~StepCustomCodeWidget() {
+ delete ui;
+}
+
+void StepCustomCodeWidget::saveChanges() {
+ QString customCode = ui->customCodeTextEdit->toPlainText();
+ if (mType == Setup && mStep->customSetupCode() != customCode) {
+ mStep->setCustomSetupCode(customCode);
+ }
+
+ if (mType == TearDown && mStep->customTearDownCode() != customCode) {
+ mStep->setCustomTearDownCode(customCode);
+ }
+}
Property changes on: trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.h
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.h (rev 0)
+++ trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.h 2010-03-09 19:16:53 UTC (rev 135)
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#ifndef STEPCUSTOMCODEWIDGET_H
+#define STEPCUSTOMCODEWIDGET_H
+
+#include "EditionWidget.h"
+
+class Step;
+
+namespace Ui {
+class CustomCodeWidget;
+}
+
+/**
+ * Edition widget for the setup and tear down code of a Step.
+ * The code that is edited (setup or tear down) is specified when the widget
+ * is created.
+ */
+class StepCustomCodeWidget: public EditionWidget {
+Q_OBJECT
+public:
+
+ enum Type {
+ Setup,
+ TearDown
+ };
+
+ /**
+ * Creates a new StepCustomCodeWidget for the given type of code of the
+ * given step.
+ *
+ * @param step The step to edit its code.
+ * @param type The type of code to edit.
+ * @param parent The parent QWidget.
+ */
+ StepCustomCodeWidget(Step* step, Type type, QWidget* parent = 0);
+
+ /**
+ * Destroys this widget.
+ */
+ virtual ~StepCustomCodeWidget();
+
+ /**
+ * Saves the code in the step.
+ */
+ virtual void saveChanges();
+
+private:
+
+ /**
+ * The step to set its code.
+ */
+ Step* mStep;
+
+ /**
+ * The type of custom code to edit.
+ */
+ Type mType;
+
+ /**
+ * The Ui Designer generated class.
+ */
+ Ui::CustomCodeWidget* ui;
+
+};
+
+#endif
Property changes on: trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.h
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp (rev 0)
+++ trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp 2010-03-09 19:16:53 UTC (rev 135)
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#include "TutorialCustomCodeWidget.h"
+
+#include <KLocalizedString>
+
+#include "ui_CustomCodeWidget.h"
+#include "../Tutorial.h"
+
+//public:
+
+TutorialCustomCodeWidget::TutorialCustomCodeWidget(Tutorial* tutorial,
+ Type type, QWidget* parent):
+ EditionWidget(parent),
+ mTutorial(tutorial),
+ mType(type) {
+
+ ui = new Ui::CustomCodeWidget();
+ ui->setupUi(this);
+
+ if (type == Setup) {
+ ui->customCodeTextEdit->setText(tutorial->customSetupCode());
+ ui->customCodeGroupBox->setTitle(i18nc("@ŧitle",
+ "Tutorial setup code"));
+ setWindowTitle(i18nc("@title", "Set the tutorial setup code"));
+ setWhatsThis(i18nc("@info:whatsthis", "<para>Set the code to be "
+"executed when the tutorial starts.</para>"
+"<para>The code will be written as is to the setup of the tutorial, after the "
+"setup code generated automatically by the editor. This means that the code "
+"must be written in the same programming language the tutorial will be "
+"exported to.</para>"));
+ } else {
+ ui->customCodeTextEdit->setText(tutorial->customTearDownCode());
+ ui->customCodeGroupBox->setTitle(i18nc("@ŧitle",
+ "Tutorial tear down code"));
+ setWindowTitle(i18nc("@title", "Set the tutorial tear down code"));
+ setWhatsThis(i18nc("@info:whatsthis", "<para>Set the code to be "
+"executed when the tutorial finishes.</para>"
+"<para>The code will be written as is to the tear down of the tutorial, before "
+"the tear down code generated automatically by the editor. This means that the "
+"code must be written in the same programming language the tutorial will be "
+"exported to.</para>"));
+ }
+}
+
+TutorialCustomCodeWidget::~TutorialCustomCodeWidget() {
+ delete ui;
+}
+
+void TutorialCustomCodeWidget::saveChanges() {
+ QString customCode = ui->customCodeTextEdit->toPlainText();
+ if (mType == Setup && mTutorial->customSetupCode() != customCode) {
+ mTutorial->setCustomSetupCode(customCode);
+ }
+
+ if (mType == TearDown && mTutorial->customTearDownCode() != customCode) {
+ mTutorial->setCustomTearDownCode(customCode);
+ }
+}
Property changes on: trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.h
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.h (rev 0)
+++ trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.h 2010-03-09 19:16:53 UTC (rev 135)
@@ -0,0 +1,84 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#ifndef TUTORIALCUSTOMCODEWIDGET_H
+#define TUTORIALCUSTOMCODEWIDGET_H
+
+#include "EditionWidget.h"
+
+class Tutorial;
+
+namespace Ui {
+class CustomCodeWidget;
+}
+
+/**
+ * Edition widget for the setup and tear down code of a Tutorial.
+ * The code that is edited (setup or tear down) is specified when the widget
+ * is created.
+ */
+class TutorialCustomCodeWidget: public EditionWidget {
+Q_OBJECT
+public:
+
+ enum Type {
+ Setup,
+ TearDown
+ };
+
+ /**
+ * Creates a new TutorialCustomCodeWidget for the given type of code of the
+ * given tutorial.
+ *
+ * @param tutorial The tutorial to edit its code.
+ * @param type The type of code to edit.
+ * @param parent The parent QWidget.
+ */
+ TutorialCustomCodeWidget(Tutorial* tutorial, Type type,
+ QWidget* parent = 0);
+
+ /**
+ * Destroys this widget.
+ */
+ virtual ~TutorialCustomCodeWidget();
+
+ /**
+ * Saves the code in the tutorial.
+ */
+ virtual void saveChanges();
+
+private:
+
+ /**
+ * The tutorial to set its code.
+ */
+ Tutorial* mTutorial;
+
+ /**
+ * The type of custom code to edit.
+ */
+ Type mType;
+
+ /**
+ * The Ui Designer generated class.
+ */
+ Ui::CustomCodeWidget* ui;
+
+};
+
+#endif
Property changes on: trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt
===================================================================
--- trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-03-09 16:14:46 UTC (rev 134)
+++ trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-03-09 19:16:53 UTC (rev 135)
@@ -16,7 +16,7 @@
ENDFOREACH(_className)
ENDMACRO(UNIT_TESTS)
-unit_tests(EditionDialog StepDataWidget StepTreeItem TextTreeItem TreeItem TreeItemUtil TreeModel TutorialInformationWidget TutorialTreeItem TutorialTreeSelectionManager)
+unit_tests(EditionDialog StepCustomCodeWidget StepDataWidget StepTreeItem TextTreeItem TreeItem TreeItemUtil TreeModel TutorialCustomCodeWidget TutorialInformationWidget TutorialTreeItem TutorialTreeSelectionManager)
MACRO(MEM_TESTS)
FOREACH(_testname ${ARGN})
@@ -24,4 +24,4 @@
ENDFOREACH(_testname)
ENDMACRO(MEM_TESTS)
-mem_tests(EditionDialog StepDataWidget StepTreeItem TextTreeItem TreeItem TreeItemUtil TreeModel TutorialInformationWidget TutorialTreeItem TutorialTreeSelectionManager)
+mem_tests(EditionDialog StepCustomCodeWidget StepDataWidget StepTreeItem TextTreeItem TreeItem TreeItemUtil TreeModel TutorialCustomCodeWidget TutorialInformationWidget TutorialTreeItem TutorialTreeSelectionManager)
Added: trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp (rev 0)
+++ trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp 2010-03-09 19:16:53 UTC (rev 135)
@@ -0,0 +1,108 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#include <QtTest>
+
+#include "StepCustomCodeWidget.h"
+
+#include <KLineEdit>
+#include <KTextEdit>
+
+#include "../Step.h"
+
+class StepCustomCodeWidgetTest: public QObject {
+Q_OBJECT
+
+private slots:
+
+ void testConstructorSetup();
+ void testConstructorTearDown();
+
+ void testSaveChangesSetup();
+ void testSaveChangesTearDown();
+
+private:
+
+ KTextEdit* customCodeTextEdit(StepCustomCodeWidget* widget) const;
+
+};
+
+void StepCustomCodeWidgetTest::testConstructorSetup() {
+ Step step;
+ step.setCustomSetupCode("The setup code");
+
+ QWidget parent;
+ StepCustomCodeWidget* widget =
+ new StepCustomCodeWidget(&step,
+ StepCustomCodeWidget::Setup,
+ &parent);
+
+ QCOMPARE(widget->parentWidget(), &parent);
+ QCOMPARE(customCodeTextEdit(widget)->toPlainText(),
+ QString("The setup code"));
+}
+
+void StepCustomCodeWidgetTest::testConstructorTearDown() {
+ Step step;
+ step.setCustomTearDownCode("The tear down code");
+
+ QWidget parent;
+ StepCustomCodeWidget* widget =
+ new StepCustomCodeWidget(&step,
+ StepCustomCodeWidget::TearDown,
+ &parent);
+
+ QCOMPARE(widget->parentWidget(), &parent);
+ QCOMPARE(customCodeTextEdit(widget)->toPlainText(),
+ QString("The tear down code"));
+}
+
+void StepCustomCodeWidgetTest::testSaveChangesSetup() {
+ Step step;
+ step.setCustomSetupCode("The setup code");
+
+ StepCustomCodeWidget widget(&step, StepCustomCodeWidget::Setup);
+ customCodeTextEdit(&widget)->setText("The new setup code");
+
+ widget.saveChanges();
+
+ QCOMPARE(step.customSetupCode(), QString("The new setup code"));
+}
+
+void StepCustomCodeWidgetTest::testSaveChangesTearDown() {
+ Step step;
+ step.setCustomTearDownCode("The tear down code");
+
+ StepCustomCodeWidget widget(&step, StepCustomCodeWidget::TearDown);
+ customCodeTextEdit(&widget)->setText("The new tear down code");
+
+ widget.saveChanges();
+
+ QCOMPARE(step.customTearDownCode(), QString("The new tear down code"));
+}
+
+/////////////////////////////////// Helpers ////////////////////////////////////
+
+KTextEdit* StepCustomCodeWidgetTest::customCodeTextEdit(
+ StepCustomCodeWidget* widget) const {
+ return widget->findChild<KTextEdit*>("customCodeTextEdit");
+}
+
+QTEST_MAIN(StepCustomCodeWidgetTest)
+
+#include "StepCustomCodeWidgetTest.moc"
Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp (rev 0)
+++ trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp 2010-03-09 19:16:53 UTC (rev 135)
@@ -0,0 +1,109 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#include <QtTest>
+
+#include "TutorialCustomCodeWidget.h"
+
+#include <KLineEdit>
+#include <KTextEdit>
+
+#include "../Tutorial.h"
+
+class TutorialCustomCodeWidgetTest: public QObject {
+Q_OBJECT
+
+private slots:
+
+ void testConstructorSetup();
+ void testConstructorTearDown();
+
+ void testSaveChangesSetup();
+ void testSaveChangesTearDown();
+
+private:
+
+ KTextEdit* customCodeTextEdit(TutorialCustomCodeWidget* widget) const;
+
+};
+
+void TutorialCustomCodeWidgetTest::testConstructorSetup() {
+ Tutorial tutorial;
+ tutorial.setCustomSetupCode("The setup code");
+
+ QWidget parent;
+ TutorialCustomCodeWidget* widget =
+ new TutorialCustomCodeWidget(&tutorial,
+ TutorialCustomCodeWidget::Setup,
+ &parent);
+
+ QCOMPARE(widget->parentWidget(), &parent);
+ QCOMPARE(customCodeTextEdit(widget)->toPlainText(),
+ QString("The setup code"));
+}
+
+void TutorialCustomCodeWidgetTest::testConstructorTearDown() {
+ Tutorial tutorial;
+ tutorial.setCustomTearDownCode("The tear down code");
+
+ QWidget parent;
+ TutorialCustomCodeWidget* widget =
+ new TutorialCustomCodeWidget(&tutorial,
+ TutorialCustomCodeWidget::TearDown,
+ &parent);
+
+ QCOMPARE(widget->parentWidget(), &parent);
+ QCOMPARE(customCodeTextEdit(widget)->toPlainText(),
+ QString("The tear down code"));
+}
+
+void TutorialCustomCodeWidgetTest::testSaveChangesSetup() {
+ Tutorial tutorial;
+ tutorial.setCustomSetupCode("The setup code");
+
+ TutorialCustomCodeWidget widget(&tutorial, TutorialCustomCodeWidget::Setup);
+ customCodeTextEdit(&widget)->setText("The new setup code");
+
+ widget.saveChanges();
+
+ QCOMPARE(tutorial.customSetupCode(), QString("The new setup code"));
+}
+
+void TutorialCustomCodeWidgetTest::testSaveChangesTearDown() {
+ Tutorial tutorial;
+ tutorial.setCustomTearDownCode("The tear down code");
+
+ TutorialCustomCodeWidget widget(&tutorial,
+ TutorialCustomCodeWidget::TearDown);
+ customCodeTextEdit(&widget)->setText("The new tear down code");
+
+ widget.saveChanges();
+
+ QCOMPARE(tutorial.customTearDownCode(), QString("The new tear down code"));
+}
+
+/////////////////////////////////// Helpers ////////////////////////////////////
+
+KTextEdit* TutorialCustomCodeWidgetTest::customCodeTextEdit(
+ TutorialCustomCodeWidget* widget) const {
+ return widget->findChild<KTextEdit*>("customCodeTextEdit");
+}
+
+QTEST_MAIN(TutorialCustomCodeWidgetTest)
+
+#include "TutorialCustomCodeWidgetTest.moc"
Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp
___________________________________________________________________
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|