From f1ca9056a0a0705496b180400502d363a7521a36 Mon Sep 17 00:00:00 2001
From: Sergei <31967497+SPetrenko17@users.noreply.github.com>
Date: Sat, 9 Nov 2019 14:09:16 +0300
Subject: [PATCH 1/5] Add files via upload
---
CMakeLists.txt | 6 +
ContainerView.cpp | 35 ++++++
ContainerView.h | 34 ++++++
Google_tests/CMakeLists.txt | 5 +
Google_tests/page_tests.cpp | 87 +++++++++++++++
Google_tests/view_tests.cpp | 215 ++++++++++++++++++++++++++++++++++++
Page.cpp | 77 +++++++++++++
Page.h | 65 +++++++++++
View.cpp | 130 ++++++++++++++++++++++
View.h | 105 ++++++++++++++++++
main.cpp | 6 +
11 files changed, 765 insertions(+)
create mode 100644 CMakeLists.txt
create mode 100644 ContainerView.cpp
create mode 100644 ContainerView.h
create mode 100644 Google_tests/CMakeLists.txt
create mode 100644 Google_tests/page_tests.cpp
create mode 100644 Google_tests/view_tests.cpp
create mode 100644 Page.cpp
create mode 100644 Page.h
create mode 100644 View.cpp
create mode 100644 View.h
create mode 100644 main.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..9acc53f
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.14)
+project(CPProject)
+
+set(CMAKE_CXX_STANDARD 14)
+add_subdirectory(Google_tests)
+add_executable(CPProject main.cpp ContainerView.cpp ContainerView.h View.cpp View.h Page.cpp Page.h )
diff --git a/ContainerView.cpp b/ContainerView.cpp
new file mode 100644
index 0000000..7e18e0a
--- /dev/null
+++ b/ContainerView.cpp
@@ -0,0 +1,35 @@
+//
+// Created by Сергей Петренко on 2019-11-07.
+//
+
+#include "ContainerView.h"
+
+ContainerView::ContainerView() {
+
+}
+
+ContainerView *ContainerView::get_parent() {
+ return nullptr;
+}
+
+void ContainerView::set_parent(ContainerView *containerView) {
+
+}
+
+string ContainerView::get_selector() {
+ return std::string();
+}
+
+string ContainerView::get_type() {
+ return std::string();
+}
+
+void ContainerView::set_type(string m_type) {
+
+}
+
+string ContainerView::get_path() {
+ return std::string();
+}
+
+
diff --git a/ContainerView.h b/ContainerView.h
new file mode 100644
index 0000000..f6a6e7e
--- /dev/null
+++ b/ContainerView.h
@@ -0,0 +1,34 @@
+//
+// Created by Сергей Петренко on 2019-11-07.
+//
+
+#ifndef CPPROJECT_CONTAINERVIEW_H
+#define CPPROJECT_CONTAINERVIEW_H
+#include
+#include
+#include
");
+}
+TEST_F(TestViews, test_remove_subview)
+{
+ view->set_view_template("*name=*
");
+ view->set_name("string_view");
+ View *subview = new View();
+ subview->set_view_template("*name=*
");
+ subview->set_name("substring_view");
+ view->append_in_subview(*subview,view->get_path());
+ view->remove_subview(*view,subview->get_path());
+ ASSERT_EQ(view->to_string(*string_property),
+ "name=sting_view
");
+}
+TEST_F(TestViews, test_remove_subview_by_name)
+{
+ view->set_view_template("*name=*
");
+ view->set_name("string_view");
+ View *subview = new View();
+ subview->set_view_template("*name=*
");
+ subview->set_name("substring_view");
+ view->append_in_subview(*subview,view->get_path());
+ view->remove_subview(*view,
+ view->get_subview_by_name(*view,"subsring_view").get_path());
+ ASSERT_EQ(view->to_string(*string_property),
+ "name=sting_view
");
+}
+
+
+class TestTextViews : public ::testing::Test
+{
+protected:
+ void SetUp() override
+ {
+ string_property = new StringProperty();
+ tv = new TextView();
+
+ }
+ void TearDown() override
+ {
+ delete string_property;
+ delete tv;
+ }
+ TextView *tv;
+ StringProperty *string_property;
+};
+TEST_F(TestTextViews, test_to_string)
+{
+ tv->set_view_template("*name=**text*
");
+ tv->set_name("text_view");
+ tv->set_text("sample_text");
+ ASSERT_EQ(tv->to_string(*string_property), "name=sting_view sample_text
");
+}
+
+class TestImageViews : public ::testing::Test
+{
+protected:
+ void SetUp() override
+ {
+ string_property = new StringProperty();
+ iv = new ImageView();
+
+ }
+ void TearDown() override
+ {
+ delete string_property;
+ delete iv;
+ }
+ ImageView *iv;
+ StringProperty *string_property;
+};
+TEST_F(TestImageViews, test_to_string)
+{
+ iv->set_view_template("*name=**img=*
");
+ iv->set_name("text_view");
+ iv->set_image_path("image_path");
+ ASSERT_EQ(iv->to_string(*string_property), "name=sting_view sample_text
");
+}
+
+class TestButtons : public ::testing::Test
+{
+protected:
+ void SetUp() override
+ {
+ string_property = new StringProperty();
+ button = new Button();
+
+ }
+ void TearDown() override
+ {
+ delete string_property;
+ delete button;
+ }
+ Button* button;
+ StringProperty *string_property;
+};
+TEST_F(TestButtons, test_to_string)
+{
+ button->TextView::set_view_template("template_for_button");
+ button->TextView::set_name("button_name");
+ button->ImageView::set_image_path("image_path");
+ ASSERT_EQ(button->TextView::to_string(*string_property),
+ "template_for_button_with_params");
+}
+
+class TestTableViews : public ::testing::Test
+{
+protected:
+ void SetUp() override
+ {
+ string_property = new StringProperty();
+ tableView = new TableView(2,2);
+ columnView = new ColumnView(tableView->get_row_count());
+ rowView = new RowView();
+ }
+ void TearDown() override
+ {
+ delete string_property;
+ delete rowView;
+ delete columnView;
+ delete tableView;
+ }
+ RowView *rowView;
+ ColumnView *columnView;
+ TableView *tableView;
+ StringProperty *string_property;
+};
+
+TEST_F(TestTableViews, test_append)
+{
+ tableView->set_view_template("table_view_template");
+ tableView->set_name("table_view_name");
+ tableView->append_in_row(View(),"container/table/row");
+ ASSERT_EQ( tableView->to_string(*string_property),
+ "template_for_tableview_with_params_and_new_row");
+}
+TEST_F(TestTableViews, test_delete)
+{
+ tableView->set_view_template("table_view_template");
+ tableView->set_name("table_view_name");
+ tableView->remove_row(View(),"container/table/row");
+ tableView->remove_column(View(),"container/table/row");
+ ASSERT_EQ( tableView->to_string(*string_property),
+ "template_for_tableview_with_deleted_rows_and_columns");
+}
+
+TEST_F(TestTableViews, test_index_for_columns)
+{
+ tableView->set_view_template("table_view_template");
+ tableView->set_name("table_view_name");
+ tableView->remove_row(View(),"container/table/row");
+ tableView->remove_column(View(),"container/table/column");
+ ASSERT_THROW(tableView->remove_row(View(),"container/table/row"), std::out_of_range);
+}
+
+
+
+
+
+
diff --git a/Page.cpp b/Page.cpp
new file mode 100644
index 0000000..3fe3bff
--- /dev/null
+++ b/Page.cpp
@@ -0,0 +1,77 @@
+//
+// Created by Сергей Петренко on 2019-11-07.
+//
+
+#include "Page.h"
+
+PageGenerator::PageGenerator() {
+
+}
+
+Page PageGenerator::generate_start_page() {
+ return Page();
+}
+
+Page PageGenerator::generate_result_page(PageData m_data) {
+ return Page();
+}
+
+PageData PageGenerator::get_page_data() {
+ return PageData();
+}
+
+void PageManager::get_from_server() {
+
+}
+
+void PageManager::push_to_server() {
+
+}
+
+PageManager::PageManager() {
+
+}
+
+PageManager::PageManager(PageData m_data) {
+
+}
+
+PageGenerator PageManager::get_page_generator() {
+ return PageGenerator();
+}
+
+Page::Page() {
+
+}
+
+void Page::append_to_head(PageData page_data, string sv_path) {
+
+}
+
+void Page::append_in_view(PageData page_data, string sv_path) {
+
+}
+
+void Page::delete_view(string m_name) {
+
+}
+
+string Page::to_string() {
+ return std::string();
+}
+
+Page::Page(PageData page_data) {
+
+}
+
+
+void PageData::get_static() {
+}
+
+PageData::PageData(string response_from_server) {
+
+}
+
+PageData::PageData() {
+
+}
diff --git a/Page.h b/Page.h
new file mode 100644
index 0000000..5d6e78a
--- /dev/null
+++ b/Page.h
@@ -0,0 +1,65 @@
+//
+// Created by Сергей Петренко on 2019-11-07.
+//
+
+#ifndef CPPROJECT_PAGE_H
+#define CPPROJECT_PAGE_H
+
+
+#include "View.h"
+#include
+
+using std::string;
+using std::vector;
+class PageData{
+public:
+ PageData();
+ PageData(string response_from_server);
+ vector image_urls;
+ vector user_urls;
+ map static_files;
+ void get_static();
+};
+
+
+class Page {
+protected:
+ View view;
+public:
+ Page();
+ Page(PageData page_data);
+ void append_to_head(PageData page_data, string sv_path);
+ void append_in_view(PageData page_data, string sv_path);
+ void delete_view(string m_name);
+ string to_string();
+};
+
+class PageGenerator{
+private:
+ string url;
+ PageData data;
+protected:
+ Page page;
+public:
+ PageGenerator();
+ Page generate_start_page();
+ Page generate_result_page(PageData m_data);
+ PageData get_page_data();
+
+};
+
+class PageManager{
+private:
+ PageData data;
+ PageGenerator pageGenerator;
+public:
+ PageManager();
+ PageManager(PageData m_data);
+ void get_from_server();
+ void push_to_server();
+ PageGenerator get_page_generator();
+
+};
+
+
+#endif //CPPROJECT_PAGE_H
diff --git a/View.cpp b/View.cpp
new file mode 100644
index 0000000..86eece1
--- /dev/null
+++ b/View.cpp
@@ -0,0 +1,130 @@
+//
+// Created by Сергей Петренко on 2019-11-07.
+//
+
+#include "View.h"
+
+void View::append_in_subview(View m_view, string sv_path) {
+
+}
+
+
+
+View::View() {
+
+}
+
+View::View(string m_view_template) {
+
+}
+
+View View::get_subview_by_name(View m_view, string name) {
+ return View();
+}
+
+string View::to_string(StringProperty property) {
+ return std::string();
+}
+
+void View::set_name(string m_name) {
+
+}
+
+void View::set_view_template(string m_view_template) {
+
+}
+
+string View::get_view_template() {
+ return std::string();
+}
+
+string View::get_name() {
+ return std::string();
+}
+
+void View::remove_subview(View m_view, string sv_path) {
+
+}
+
+ImageView::ImageView() {
+
+}
+
+ImageView::ImageView(string m_image_path) : View(m_image_path) {
+
+}
+
+void ImageView::set_image_path(string m_image_path) {
+
+}
+
+string ImageView::get_image_path() {
+ return std::string();
+}
+
+StringProperty::StringProperty() {
+
+}
+
+TextView::TextView() {
+
+}
+
+TextView::TextView(string m_text) : View(m_text) {
+
+}
+
+void TextView::set_text(string m_text) {
+
+}
+
+string TextView::get_text() {
+ return std::string();
+}
+
+Button::Button() {
+
+}
+
+Button::Button(string path, string text) {
+
+}
+
+RowView::RowView() {
+
+}
+
+ColumnView::ColumnView() {
+
+}
+
+ColumnView::ColumnView(int rows_count) {
+
+}
+
+TableView::TableView() {
+
+}
+
+TableView::TableView(int rows, int columns) {
+
+}
+
+void TableView::append_in_row(View m_view, string path) {
+
+}
+
+int TableView::get_row_count() {
+ return 0;
+}
+
+int TableView::get_colums_count() {
+ return 0;
+}
+
+void TableView::remove_column(View m_view, string path) {
+
+}
+void TableView::remove_row(View m_view, string path) {
+
+}
\ No newline at end of file
diff --git a/View.h b/View.h
new file mode 100644
index 0000000..49a5269
--- /dev/null
+++ b/View.h
@@ -0,0 +1,105 @@
+//
+// Created by Сергей Петренко on 2019-11-07.
+//
+
+#ifndef CPPROJECT_VIEW_H
+#define CPPROJECT_VIEW_H
+
+
+#include "ContainerView.h"
+#include
+#include
+#include
+#include