fixup! Implementation of ewk_home_directory_set API.
authorWojciech Bielawski <w.bielawski@samsung.com>
Mon, 19 Jan 2015 12:21:27 +0000 (13:21 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Applied changes after review on dev/master branch

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9555
Reviewed by: Antonio Gomes, Janusz Majnert, Piotr Tworek

Change-Id: I4c54926f92e03aede254ad483c6223af4aa0b304
Signed-off-by: Wojciech Bielawski <w.bielawski@samsung.com>
tizen_src/ewk/efl_integration/private/ewk_main_private.cc
tizen_src/ewk/efl_integration/private/ewk_main_private.h
tizen_src/ewk/efl_integration/public/ewk_main.cc
tizen_src/ewk/efl_integration/public/ewk_main.h
tizen_src/ewk/unittest/utc_blink_ewk_home_directory_get_func.cpp
tizen_src/ewk/unittest/utc_blink_ewk_home_directory_set_func.cpp

index c706779..b65bfc7 100644 (file)
@@ -1,31 +1,16 @@
-/*
- * 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)
@@ -35,4 +20,3 @@ const char* ewk_home_directory_get()
 
   return home;
 }
-
index a7f3ee2..46b1da3 100644 (file)
@@ -1,33 +1,18 @@
-/*
- * 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
index a0758cc..46a5289 100644 (file)
@@ -50,6 +50,8 @@ static int _ewkInitCount = 0;
 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
@@ -168,7 +170,10 @@ void ewk_set_arguments(int argc, char** argv)
 
 void ewk_home_directory_set(const char* path)
 {
-  m_homeDirectory = path;
+  if (!path)
+    g_homeDirectory.clear();
+  else
+    g_homeDirectory = path;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
index 1461f9b..57c995e 100644 (file)
@@ -61,6 +61,9 @@ EAPI void ewk_set_arguments(int argc, char** argv);
 
 /**
 * 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);
 
index 60c7bb0..dbcea99 100644 (file)
@@ -1,23 +1,6 @@
-/*
- * 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"
index 152b921..1f900d5 100644 (file)
@@ -1,23 +1,6 @@
-/*
- * 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"
@@ -40,6 +23,18 @@ TEST_F(utc_blink_ewk_home_directory_set, POS_TEST1)
 }
 
 /**
+ * @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)
@@ -55,6 +50,16 @@ 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");