[vte] all: Add test mode
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] all: Add test mode
- Date: Sun, 4 Mar 2018 22:22:44 +0000 (UTC)
commit bac521b55ec8df9de486c318094fa3d016b7ec8a
Author: Christian Persch <chpe src gnome org>
Date: Sun Mar 4 23:22:26 2018 +0100
all: Add test mode
Add a way to enable test mode, which will activate functions
that are normally not enabled (for whatever reason).
Add --test-mode to the vteapp to activate test mode. This
will later be used in automatic tests.
src/app/app.cc | 12 +++++++++++-
src/vte.cc | 17 +++++++++++++----
src/vtegtk.cc | 7 +++++++
src/vteinternal.hh | 5 ++++-
4 files changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/src/app/app.cc b/src/app/app.cc
index 695de98..854ccbe 100644
--- a/src/app/app.cc
+++ b/src/app/app.cc
@@ -56,6 +56,7 @@ public:
gboolean no_shell{false};
gboolean object_notifications{false};
gboolean reverse{false};
+ gboolean test_mode{false};
gboolean use_gregex{false};
gboolean version{false};
gboolean whole_window_transparent{false};
@@ -433,7 +434,10 @@ public:
&dummy_bool, nullptr, nullptr },
{ "shell", 'S', G_OPTION_FLAG_REVERSE | G_OPTION_FLAG_HIDDEN,
G_OPTION_ARG_NONE, &no_shell, nullptr, nullptr },
-
+#ifdef VTE_DEBUG
+ { "test-mode", 0, 0, G_OPTION_ARG_NONE, &test_mode,
+ "Enable test mode", nullptr },
+#endif
{ nullptr }
};
@@ -2105,6 +2109,12 @@ main(int argc,
if (options.debug)
gdk_window_set_debug_updates(true);
+#ifdef VTE_DEBUG
+ if (options.test_mode) {
+ g_setenv("VTE_TEST", "1", true);
+ options.allow_window_ops = true;
+ }
+#endif
auto app = vteapp_application_new();
auto rv = g_application_run(app, 0, nullptr);
diff --git a/src/vte.cc b/src/vte.cc
index 8a4809a..47fc4c1 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -4090,7 +4090,8 @@ out:
*/
void
VteTerminalPrivate::feed(char const* data,
- gssize length)
+ gssize length,
+ bool start_processing_)
{
g_assert(length == 0 || data != nullptr);
@@ -4122,7 +4123,8 @@ VteTerminalPrivate::feed(char const* data,
feed_chunks(chunk);
} while (1);
- start_processing();
+ if (start_processing_)
+ start_processing();
}
}
@@ -8284,13 +8286,20 @@ VteTerminalPrivate::VteTerminalPrivate(VteTerminal *t) :
m_padding = default_padding;
update_view_extents();
+#ifdef VTE_DEBUG
+ if (g_test_mode) {
+ static char const warning[] = "\e[1m\e[31mWARNING:\e[39m Test mode enabled.\e[0m\n\e[G";
+ feed(warning, strlen(warning), false);
+ }
+#endif
+
#ifndef WITH_GNUTLS
{
char buf[1024];
- auto len = g_snprintf(buf, sizeof(buf), "\e[1m\e[31m%s:\e[39m %s\e[0m\n",
+ auto len = g_snprintf(buf, sizeof(buf), "\e[1m\e[31m%s:\e[39m %s\e[0m\n\e[G",
_("WARNING"),
_("GNUTLS not enabled; data will be written to disk unencrypted!"));
- feed(buf, len);
+ feed(buf, len, false);
}
#endif
}
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 261d2da..516e042 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -89,6 +89,7 @@ G_DEFINE_TYPE_WITH_CODE(VteTerminal, vte_terminal, GTK_TYPE_WIDGET,
guint signals[LAST_SIGNAL];
GParamSpec *pspecs[LAST_PROP];
GTimer *process_timer;
+bool g_test_mode = false;
static bool
valid_color(GdkRGBA const* color)
@@ -649,6 +650,12 @@ vte_terminal_class_init(VteTerminalClass *klass)
" = vte_terminal_paint\n"
" ]} end update_timeout\n"
" > end process_timeout\n");
+
+ char const* test_env = g_getenv("VTE_TEST");
+ if (test_env != nullptr) {
+ g_test_mode = g_str_equal(test_env, "1");
+ g_unsetenv("VTE_TEST");
+ }
}
#endif
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index ba8bd10..a58a005 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -958,7 +958,8 @@ public:
bool from_api = false);
void feed(char const* data,
- gssize length);
+ gssize length,
+ bool start_processsing_ = true);
void feed_child(char const *text,
gssize length);
void feed_child_binary(guint8 const* data,
@@ -1382,3 +1383,5 @@ _vte_double_equal(double a,
return a == b;
#pragma GCC diagnostic pop
}
+
+extern bool g_test_mode;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]