-/*
- * Copyright (C) 2014 Samsung Electronics
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
+// Copyright 2013 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include "ewk_main_private.h"
#include "webview_delegate_ewk.h"
-const char* m_homeDirectory = NULL;
+std::string g_homeDirectory;
const char* ewk_home_directory_get()
{
- if (m_homeDirectory && m_homeDirectory[0])
- return m_homeDirectory;
+ if (!g_homeDirectory.empty())
+ return g_homeDirectory.c_str();
const char *home = getenv("HOME");
if (!home)
return home;
}
-
-/*
- * Copyright (C) 2014 Samsung Electronics
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
+// Copyright 2013 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#ifndef ewk_main_private_h
#define ewk_main_private_h
#include "ewk_export.h"
-
-extern const char* m_homeDirectory;
+#include <string>
/**
* Returns home directory.
*
- * If home directory is not previously set by ewk_home_directory_set() then $HOME envvar is returned.
+ * If home directory is not previously set by ewk_home_directory_set() then
+ * the content of $HOME variable is returned.
* If $HOME is not set then "/tmp" is returned.
*
* @return home directory
static void _ewk_init_web_engine(void);
static void _ewk_shutdown_web_engine(void);
+extern std::string g_homeDirectory;
+
/**
* \var _ewk_log_dom
* @brief the log domain identifier that is used with EINA's macros
void ewk_home_directory_set(const char* path)
{
- m_homeDirectory = path;
+ if (!path)
+ g_homeDirectory.clear();
+ else
+ g_homeDirectory = path;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/**
* Set home directory.
+*
+* If new path is NULL or empty string, home directory is considered as not set.
+*
*/
EAPI void ewk_home_directory_set(const char* path);
-/*
- * Chromium EFL
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
+// Copyright 2014 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include "utc_blink_ewk_base.h"
#include "../private/ewk_main_private.h"
-/*
- * Chromium EFL
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
+// Copyright 2014 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include "utc_blink_ewk_base.h"
#include "../private/ewk_main_private.h"
}
/**
+ * @brief Test if home directory path is internally stored.
+ */
+TEST_F(utc_blink_ewk_home_directory_set, POS_TEST2)
+{
+ char* test = strdup("/foobar");
+ ewk_home_directory_set(test);
+ const char* home_dir = ewk_home_directory_get();
+ test[0] = 'A';
+ ASSERT_STRNE(test, home_dir);
+}
+
+/**
* @brief Test if function works correctly with NULL argument.
*/
TEST_F(utc_blink_ewk_home_directory_set, NEG_TEST1)
utc_message("Home dir == %s", ewk_home_dir);
// Check if it was changed
ASSERT_STRNE(new_dir, ewk_home_dir);
+ ASSERT_STRNE("", ewk_home_dir);
+ ASSERT_TRUE(ewk_home_dir);
+
+ // Check behavior with empty string
+ ewk_home_directory_set("");
+ ewk_home_dir = ewk_home_directory_get();
+ utc_message("Home dir == %s", ewk_home_dir);
+ // Assuming $HOME is not defined as empty string
+ ASSERT_STRNE("", ewk_home_dir);
+ ASSERT_TRUE(ewk_home_dir);
// Check if it was returned as one of the the expected values
const char* home_dir = getenv("HOME");