summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-09-16 15:23:16 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-09-16 15:23:16 (GMT)
commitd90e4acfa7b0d1be202d56441e9912417147af26 (patch)
tree82b9d8588618c73b993520a0a888988bd2b9ce7b
parent2385b2b0ad832825bd9009237149e1581326c044 (diff)
downloadhdf5-d90e4acfa7b0d1be202d56441e9912417147af26.zip
hdf5-d90e4acfa7b0d1be202d56441e9912417147af26.tar.gz
hdf5-d90e4acfa7b0d1be202d56441e9912417147af26.tar.bz2
[svn-r27801] Minor warning fixes in the tools.
Tested on: jam (too minor for h5committest)
-rw-r--r--tools/h5diff/h5diffgentest.c119
-rw-r--r--tools/h5dump/h5dump_ddl.c13
-rw-r--r--tools/h5dump/h5dump_ddl.h4
-rw-r--r--tools/h5dump/h5dump_defines.h30
-rw-r--r--tools/h5dump/h5dump_xml.c14
-rw-r--r--tools/h5import/h5import.c22
-rw-r--r--tools/h5repack/h5repack_verify.c16
-rw-r--r--tools/h5stat/h5stat_gentest.c16
-rw-r--r--tools/lib/h5diff.c4
-rw-r--r--tools/lib/h5tools.c16
-rw-r--r--tools/lib/h5tools.h4
-rw-r--r--tools/lib/h5tools_dump.c8
-rw-r--r--tools/misc/talign.c10
-rw-r--r--tools/perform/pio_perf.c59
-rw-r--r--tools/perform/sio_perf.c53
15 files changed, 152 insertions, 236 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index a871709..8f92660 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -1014,14 +1014,14 @@ int test_attributes(const char *file,
static int test_attributes_verbose_level(const char *fname1, const char *fname2)
{
herr_t status = SUCCEED;
- hid_t fid1, fid2;
- hid_t f1_gid, f2_gid;
- hid_t f1_gid2, f2_gid2;
- hid_t f1_gid3, f2_gid3;
- hid_t f1_gid4, f2_gid4;
- hid_t f1_did, f2_did;
- hid_t f1_sid, f2_sid;
- hid_t f1_tid, f2_tid;
+ hid_t fid1 = -1, fid2 = -1;
+ hid_t f1_gid = -1, f2_gid = -1;
+ hid_t f1_gid2 = -1, f2_gid2 = -1;
+ hid_t f1_gid3 = -1, f2_gid3 = -1;
+ hid_t f1_gid4 = -1, f2_gid4 = -1;
+ hid_t f1_did = -1, f2_did = -1;
+ hid_t f1_sid = -1, f2_sid = -1;
+ hid_t f1_tid = -1, f2_tid = -1;
/* dset */
hsize_t dset_dims[1]={3};
int dset_data[3] = {0,1,2};
@@ -1252,9 +1252,9 @@ out:
/*-----------------------------------------------------------------------
* Close
*-----------------------------------------------------------------------*/
- if(fid1)
+ if(fid1 > 0)
H5Fclose(fid1);
- if(fid2)
+ if(fid2 > 0)
H5Fclose(fid2);
if(f1_gid > 0)
H5Gclose(f1_gid);
@@ -1276,13 +1276,13 @@ out:
H5Dclose(f1_did);
if(f2_did > 0)
H5Dclose(f2_did);
- if(f1_sid >0)
+ if(f1_sid > 0)
H5Sclose(f1_sid);
- if(f2_sid >0)
+ if(f2_sid > 0)
H5Sclose(f2_sid);
- if(f1_tid >0)
+ if(f1_tid > 0)
H5Tclose(f1_tid);
- if(f2_tid >0)
+ if(f2_tid > 0)
H5Tclose(f2_tid);
return status;
@@ -2797,15 +2797,18 @@ out:
#define GRP_R_DSETNAME2 "dset2"
static int test_group_recurse2(void)
{
- hid_t fileid1;
- hid_t grp1=0, grp2;
- hid_t grp3=0;
- hid_t grp4=0;
- hid_t dset1, dset2;
- hid_t datatype, dataspace; /* handles */
- hid_t fileid2;
- hid_t fileid3;
- hid_t fileid4;
+ hid_t fileid1 = -1;
+ hid_t grp1 = -1;
+ hid_t grp2 = -1;
+ hid_t grp3 = -1;
+ hid_t grp4 = -1;
+ hid_t dset1 = -1;
+ hid_t dset2 = -1;
+ hid_t datatype = -1;
+ hid_t dataspace = -1;
+ hid_t fileid2 = -1;
+ hid_t fileid3 = -1;
+ hid_t fileid4 = -1;
hsize_t dimsf[2]; /* dataset dimensions */
herr_t status=0;
int data1[4][2] = {{0,0},{1,1},{2,2},{3,3}};
@@ -3098,12 +3101,18 @@ out:
/*
* Close/release resources.
*/
- H5Sclose(dataspace);
- H5Tclose(datatype);
- H5Fclose(fileid1);
- H5Fclose(fileid2);
- H5Fclose(fileid3);
- H5Fclose(fileid4);
+ if(dataspace > 0)
+ H5Sclose(dataspace);
+ if(datatype > 0)
+ H5Tclose(datatype);
+ if(fileid1 > 0)
+ H5Fclose(fileid1);
+ if(fileid2 > 0)
+ H5Fclose(fileid2);
+ if(fileid3 > 0)
+ H5Fclose(fileid3);
+ if(fileid4 > 0)
+ H5Fclose(fileid4);
return status;
}
@@ -3506,8 +3515,8 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int
{
int i;
- hid_t fid1; /* file id */
- hid_t gid;
+ hid_t fid1 = -1; /* file id */
+ hid_t gid = -1;
/* compound1 datatype */
typedef struct comp1_t
@@ -4153,60 +4162,60 @@ out:
/*-----------------------------------------------------------------------
* Close
*-----------------------------------------------------------------------*/
- if(fid1)
+ if(fid1 > 0)
H5Fclose(fid1);
- if(gid)
+ if(gid > 0)
H5Gclose(gid);
/* vlen string */
- if(tid_vlen_str)
+ if(tid_vlen_str > 0)
H5Tclose(tid_vlen_str);
- if(sid_vlen_str)
+ if(sid_vlen_str > 0)
H5Sclose(sid_vlen_str);
/* fixed len string */
- if(tid_fixlen_str)
+ if(tid_fixlen_str > 0)
H5Tclose(tid_fixlen_str);
- if(sid_fixlen_str)
+ if(sid_fixlen_str > 0)
H5Sclose(sid_fixlen_str);
/* vlen string array */
- if(tid_vlen_str_array_pre)
+ if(tid_vlen_str_array_pre > 0)
H5Tclose(tid_vlen_str_array_pre);
- if(tid_vlen_str_array)
+ if(tid_vlen_str_array > 0)
H5Tclose(tid_vlen_str_array);
- if(sid_vlen_str_array)
+ if(sid_vlen_str_array > 0)
H5Sclose(sid_vlen_str_array);
/* fixed len string array */
- if(tid_fixlen_str_array_pre)
+ if(tid_fixlen_str_array_pre > 0)
H5Tclose(tid_fixlen_str_array_pre);
- if(tid_fixlen_str_array)
+ if(tid_fixlen_str_array > 0)
H5Tclose(tid_fixlen_str_array);
- if(sid_fixlen_str_array)
+ if(sid_fixlen_str_array > 0)
H5Sclose(sid_fixlen_str_array);
/* compound */
- if(tid1_comp)
+ if(tid1_comp > 0)
H5Tclose(tid1_comp);
- if(tid2_comp)
+ if(tid2_comp > 0)
H5Tclose(tid2_comp);
- if(tid3_comp)
+ if(tid3_comp > 0)
H5Tclose(tid3_comp);
- if(tid4_comp)
+ if(tid4_comp > 0)
H5Tclose(tid4_comp);
- if(tid5_comp)
+ if(tid5_comp > 0)
H5Tclose(tid5_comp);
- if(tid6_comp)
+ if(tid6_comp > 0)
H5Tclose(tid6_comp);
- if(tid7_comp)
+ if(tid7_comp > 0)
H5Tclose(tid7_comp);
- if(tid8_comp)
+ if(tid8_comp > 0)
H5Tclose(tid8_comp);
- if(tid9_comp)
+ if(tid9_comp > 0)
H5Tclose(tid9_comp);
- if(did_comp)
+ if(did_comp > 0)
H5Dclose(did_comp);
- if(sid_comp)
+ if(sid_comp > 0)
H5Sclose(sid_comp);
return status;
-}
+} /* end test_comp_vlen_strings() */
/*-------------------------------------------------------------------------
diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c
index 0cd0847..fd50710 100644
--- a/tools/h5dump/h5dump_ddl.c
+++ b/tools/h5dump/h5dump_ddl.c
@@ -1518,10 +1518,10 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H
void
handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name)
{
- hid_t oid = -1;
- hid_t attr_id = -1;
- char *obj_name;
- char *attr_name;
+ hid_t oid = -1;
+ hid_t attr_id = -1;
+ char *obj_name = NULL;
+ char *attr_name = NULL;
int j;
h5tools_str_t buffer; /* string into which to render */
h5tools_context_t ctx; /* print context */
@@ -1898,8 +1898,9 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT
begin_obj(h5tools_dump_header_format->softlinkbegin, links, h5tools_dump_header_format->softlinkblockbegin);
PRINTVALSTREAM(rawoutstream, "\n");
indentation(COL);
- if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0)
+ if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) {
PRINTSTREAM(rawoutstream, "LINKTARGET \"%s\"\n", buf);
+ }
else {
error_msg("h5dump error: unable to get link value for \"%s\"\n", links);
h5tools_setstatus(EXIT_FAILURE);
@@ -1941,7 +1942,7 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT
case H5L_TYPE_MAX:
HDassert(0);
/* fall through */
- H5L_TYPE_HARD:
+ case H5L_TYPE_HARD:
default:
begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin);
PRINTVALSTREAM(rawoutstream, "\n");
diff --git a/tools/h5dump/h5dump_ddl.h b/tools/h5dump/h5dump_ddl.h
index 6cd9181..2b3f61e 100644
--- a/tools/h5dump/h5dump_ddl.h
+++ b/tools/h5dump/h5dump_ddl.h
@@ -34,6 +34,10 @@ void dump_fcontents(hid_t fid);
/* callback function used by H5Aiterate2() */
herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data);
+/* other iteration functions */
+void link_iteration(hid_t gid, unsigned crt_order_flags);
+void attr_iteration(hid_t gid, unsigned attr_crt_order_flags);
+
void handle_paths(hid_t fid, const char *path_name, void *data, int pe, const char *display_name);
void handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name);
void handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name);
diff --git a/tools/h5dump/h5dump_defines.h b/tools/h5dump/h5dump_defines.h
index 5f2df43..2be2dcc 100644
--- a/tools/h5dump/h5dump_defines.h
+++ b/tools/h5dump/h5dump_defines.h
@@ -23,23 +23,25 @@
#define COL 3
/* Macros for displaying objects */
-#define begin_obj(obj,name,begin) \
- do { \
- if ((name)) \
+#define begin_obj(obj,name,begin) \
+ do { \
+ if ((name)) { \
PRINTSTREAM(rawoutstream, "%s \"%s\" %s", (obj), (name), (begin)); \
- else \
- PRINTSTREAM(rawoutstream, "%s %s", (obj), (begin)); \
+ } \
+ else { \
+ PRINTSTREAM(rawoutstream, "%s %s", (obj), (begin)); \
+ } \
} while(0);
-#define end_obj(obj,end) \
- do { \
- if(HDstrlen(end)) { \
- PRINTSTREAM(rawoutstream, "%s", end); \
- if(HDstrlen(obj)) \
- PRINTVALSTREAM(rawoutstream, " "); \
- } \
- if(HDstrlen(obj)) \
- PRINTSTREAM(rawoutstream, "%s", obj); \
+#define end_obj(obj,end) \
+ do { \
+ if(HDstrlen(end)) { \
+ PRINTSTREAM(rawoutstream, "%s", end); \
+ if(HDstrlen(obj)) \
+ PRINTVALSTREAM(rawoutstream, " "); \
+ } \
+ if(HDstrlen(obj)) \
+ PRINTSTREAM(rawoutstream, "%s", obj); \
} while(0);
diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c
index e872114..5bc43eb 100644
--- a/tools/h5dump/h5dump_xml.c
+++ b/tools/h5dump/h5dump_xml.c
@@ -2968,9 +2968,9 @@ static int
xml_print_refs(hid_t did, int source)
{
herr_t e;
- hid_t type;
- hid_t space;
- hssize_t ssiz;
+ hid_t type = -1;
+ hid_t space = -1;
+ hssize_t ssiz = -1;
hsize_t i;
size_t tsiz;
hobj_ref_t *refbuf = NULL;
@@ -3125,11 +3125,11 @@ static int
xml_print_strs(hid_t did, int source)
{
herr_t e;
- hid_t type;
- hid_t space;
- hssize_t ssiz;
+ hid_t type = -1;
+ hid_t space = -1;
+ hssize_t ssiz = -1;
htri_t is_vlstr = FALSE;
- size_t tsiz;
+ size_t tsiz = 0;
size_t i;
size_t str_size = 0;
char *bp = NULL;
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c
index 96fb6f9..9617df3 100644
--- a/tools/h5import/h5import.c
+++ b/tools/h5import/h5import.c
@@ -265,7 +265,7 @@ err:
static int gtoken(char *s)
{
size_t len;
- int token;
+ int token = ERR;
const char *err1 = "Illegal argument: %s.\n";
@@ -995,16 +995,16 @@ out:
*/
static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
{
- hid_t group_id;
- hid_t dset_id;
- hid_t space_id;
- hid_t mspace_id;
- hid_t type_id;
- hid_t handle;
- char *str1 = NULL;
- char *str2 = NULL;
- char *str3 = NULL;
- char str[1024] = "";
+ hid_t group_id = -1;
+ hid_t dset_id = -1;
+ hid_t space_id = -1;
+ hid_t mspace_id = -1;
+ hid_t type_id = -1;
+ hid_t handle = -1;
+ char *str1 = NULL;
+ char *str2 = NULL;
+ char *str3 = NULL;
+ char str[1024] = "";
int j;
hsize_t line;
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index 42799f9..52423f1 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -51,17 +51,17 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil
int
h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options)
{
- hid_t fidin; /* file ID for input file*/
- hid_t fidout; /* file ID for output file*/
- hid_t did; /* dataset ID */
- hid_t pid; /* dataset creation property list ID */
- hid_t sid; /* space ID */
- hid_t tid; /* type ID */
+ hid_t fidin = -1; /* file ID for input file*/
+ hid_t fidout = -1; /* file ID for output file*/
+ hid_t did = -1; /* dataset ID */
+ hid_t pid = -1; /* dataset creation property list ID */
+ hid_t sid = -1; /* space ID */
+ hid_t tid = -1; /* type ID */
unsigned int i;
trav_table_t *travt = NULL;
int ok = 1;
- hid_t fcpl_in; /* file creation property for input file */
- hid_t fcpl_out; /* file creation property for output file */
+ hid_t fcpl_in = -1; /* file creation property for input file */
+ hid_t fcpl_out = -1; /* file creation property for output file */
H5F_file_space_type_t in_strat, out_strat; /* file space handling strategy for in/output file */
hsize_t in_thresh, out_thresh; /* free space section threshold for in/output file */
diff --git a/tools/h5stat/h5stat_gentest.c b/tools/h5stat/h5stat_gentest.c
index 5ad73f7..100f5b2 100644
--- a/tools/h5stat/h5stat_gentest.c
+++ b/tools/h5stat/h5stat_gentest.c
@@ -48,14 +48,14 @@
static void
gen_newgrat_file(const char *fname)
{
- hid_t fcpl; /* File creation property */
- hid_t fapl; /* File access property */
- hid_t fid; /* File id */
- hid_t gid; /* Group id */
- hid_t tid; /* Datatype id */
- hid_t sid; /* Dataspace id */
- hid_t attr_id; /* Attribute id */
- hid_t did; /* Dataset id */
+ hid_t fcpl = -1; /* File creation property */
+ hid_t fapl = -1; /* File access property */
+ hid_t fid = -1; /* File id */
+ hid_t gid = -1; /* Group id */
+ hid_t tid = -1; /* Datatype id */
+ hid_t sid = -1; /* Dataspace id */
+ hid_t attr_id = -1; /* Attribute id */
+ hid_t did = -1; /* Dataset id */
char name[30]; /* Group name */
char attrname[30]; /* Attribute name */
int i; /* Local index variable */
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index badaf3c..46dcf6f 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -594,8 +594,8 @@ hsize_t h5diff(const char *fname1,
trav_info_t *info1_grp = NULL;
trav_info_t *info2_grp = NULL;
/* local pointer */
- trav_info_t *info1_lp;
- trav_info_t *info2_lp;
+ trav_info_t *info1_lp = NULL;
+ trav_info_t *info2_lp = NULL;
/* link info from specified object */
H5L_info_t src_linfo1;
H5L_info_t src_linfo2;
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 274b398..19d71bb 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1641,8 +1641,8 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
hsize_t alloc_size;
hsize_t *ptdata;
int ndims;
- hid_t dtype;
- hid_t type_id;
+ hid_t dtype = -1;
+ hid_t type_id = -1;
if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
@@ -1672,10 +1672,10 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
done:
HDfree(ptdata);
- if(H5Tclose(type_id) < 0)
+ if(type_id > 0 && H5Tclose(type_id) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Tclose(dtype) < 0)
+ if(dtype > 0 && H5Tclose(dtype) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
H5_LEAVE(TRUE)
@@ -1765,8 +1765,8 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id,
HERR_INIT(hbool_t, TRUE)
hssize_t npoints;
int ndims;
- hid_t dtype;
- hid_t type_id;
+ hid_t dtype = -1;
+ hid_t type_id = -1;
if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
@@ -1785,10 +1785,10 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id,
stream, container, ndims, type_id, npoints);
done:
- if(H5Tclose(type_id) < 0)
+ if(type_id > 0 && H5Tclose(type_id) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Tclose(dtype) < 0)
+ if(dtype > 0 && H5Tclose(dtype) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
H5_LEAVE(ret_value)
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index d6c3720..49f2dc9 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -574,8 +574,12 @@ H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_form
h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum);
H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts);
+H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
+ hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container);
+H5TOOLS_DLL int render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
+ FILE* stream, hid_t container, int ndims, hid_t type_id, hssize_t npoints);
H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container);
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 6388273..a007882 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -926,8 +926,8 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
hsize_t *ptdata;
int ndims;
hssize_t indx;
- hid_t dtype;
- hid_t type_id;
+ hid_t dtype = -1;
+ hid_t type_id = -1;
HDassert(info);
HDassert(ctx);
@@ -1048,10 +1048,10 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
done:
HDfree(ptdata);
- if(H5Tclose(type_id) < 0)
+ if(type_id > 0 && H5Tclose(type_id) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Tclose(dtype) < 0)
+ if(dtype > 0 && H5Tclose(dtype) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
ctx->need_prefix = TRUE;
diff --git a/tools/misc/talign.c b/tools/misc/talign.c
index 1a26a28..7eb4c50 100644
--- a/tools/misc/talign.c
+++ b/tools/misc/talign.c
@@ -37,11 +37,11 @@ const char *setname = "align";
int main(void)
{
- hid_t fil,spc,set;
- hid_t cs6, cmp, fix;
- hid_t cmp1, cmp2, cmp3;
- hid_t plist;
- hid_t array_dt;
+ hid_t fil=-1, spc=-1, set=-1;
+ hid_t cs6=-1, cmp=-1, fix=-1;
+ hid_t cmp1=-1, cmp2=-1, cmp3=-1;
+ hid_t plist=-1;
+ hid_t array_dt=-1;
hsize_t dim[2];
hsize_t cdim[4];
diff --git a/tools/perform/pio_perf.c b/tools/perform/pio_perf.c
index 4db2249..509513b 100644
--- a/tools/perform/pio_perf.c
+++ b/tools/perform/pio_perf.c
@@ -1673,60 +1673,8 @@ usage(const char *prog)
printf(" HDF5_MPI_INFO MPI INFO object key=value separated by ;\n");
printf(" HDF5_PARAPREFIX Paralllel data files prefix\n");
fflush(stdout);
- }
-}
-
-void debug_start_stop_time(io_time_t *pt, timer_type t, int start_stop)
-{
-#if 1
- if (pio_debug_level >= 4) {
- const char *msg;
- int myrank;
-
- MPI_Comm_rank(pio_comm_g, &myrank);
-
- switch (t) {
- case HDF5_FILE_OPENCLOSE:
- msg = "File Open/Close";
- break;
- case HDF5_DATASET_CREATE:
- msg = "Dataset Create";
- break;
- case HDF5_MPI_WRITE:
- msg = "MPI Write";
- break;
- case HDF5_MPI_READ:
- msg = "MPI Read";
- break;
- case HDF5_FINE_WRITE_FIXED_DIMS:
- msg = "Fine Write";
- break;
- case HDF5_FINE_READ_FIXED_DIMS:
- msg = "Fine Read";
- break;
- case HDF5_GROSS_WRITE_FIXED_DIMS:
- msg = "Gross Write";
- break;
- case HDF5_GROSS_READ_FIXED_DIMS:
- msg = "Gross Read";
- break;
- case HDF5_RAW_WRITE_FIXED_DIMS:
- msg = "Raw Write";
- break;
- case HDF5_RAW_READ_FIXED_DIMS:
- msg = "Raw Read";
- break;
- default:
- msg = "Unknown Timer";
- break;
- }
-
- fprintf(output, " Proc %d: %s %s: %.2f\n", myrank, msg,
- (start_stop == TSTART ? "Start" : "Stop"),
- pt->total_time[t]);
- }
-#endif
-} /* debug_start_stop_time */
+ } /* end if */
+} /* end usage() */
#else /* H5_HAVE_PARALLEL */
@@ -1736,13 +1684,12 @@ void debug_start_stop_time(io_time_t *pt, timer_type t, int start_stop)
* parallel stuff.
* Return: EXIT_SUCCESS
* Programmer: Bill Wendling, 14. November 2001
- * Modifications:
*/
int
main(void)
{
printf("No parallel IO performance because parallel is not configured\n");
return EXIT_SUCCESS;
-}
+} /* end main */
#endif /* !H5_HAVE_PARALLEL */
diff --git a/tools/perform/sio_perf.c b/tools/perform/sio_perf.c
index 34d8552..a69e929 100644
--- a/tools/perform/sio_perf.c
+++ b/tools/perform/sio_perf.c
@@ -1405,56 +1405,5 @@ usage(const char *prog)
printf(" HDF5_PREFIX Data file prefix\n");
printf("\n");
fflush(stdout);
-}
-
-void debug_start_stop_time(io_time_t *pt, timer_type t, int start_stop)
-{
- if (sio_debug_level >= 4) {
- const char *msg;
-
- switch (t) {
- case HDF5_FILE_OPENCLOSE:
- msg = "File Open/Close";
- break;
- case HDF5_DATASET_CREATE:
- msg = "Dataset Create";
- break;
- case HDF5_MPI_WRITE:
- msg = "MPI Write";
- break;
- case HDF5_MPI_READ:
- msg = "MPI Read";
- break;
- case HDF5_FINE_WRITE_FIXED_DIMS:
- msg = "Fine Write";
- break;
- case HDF5_FINE_READ_FIXED_DIMS:
- msg = "Fine Read";
- break;
- case HDF5_GROSS_WRITE_FIXED_DIMS:
- msg = "Gross Write";
- break;
- case HDF5_GROSS_READ_FIXED_DIMS:
- msg = "Gross Read";
- break;
- case HDF5_RAW_WRITE_FIXED_DIMS:
- msg = "Raw Write";
- break;
- case HDF5_RAW_READ_FIXED_DIMS:
- msg = "Raw Read";
- break;
- case HDF5_FILE_READ_OPEN:
- case HDF5_FILE_READ_CLOSE:
- case HDF5_FILE_WRITE_OPEN:
- case HDF5_FILE_WRITE_CLOSE:
- default:
- msg = "Unknown Timer";
- break;
- }
-
- fprintf(output, " %s %s: %.2f\n", msg,
- (start_stop == TSTART ? "Start" : "Stop"),
- pt->total_time[t]);
- }
-} /* debug_start_stop_time */
+} /* end usage() */
pan class="hl opt">().filePath(QLatin1String("data/lib"))); } private slots: void initTestCase(); void cleanupTestCase(); void errors_data(); void errors(); void simpleObject(); void simpleContainer(); void interfaceProperty(); void interfaceQList(); void assignObjectToSignal(); void assignObjectToVariant(); void assignLiteralSignalProperty(); void assignQmlComponent(); void assignBasicTypes(); void assignTypeExtremes(); void assignCompositeToType(); void assignLiteralToVariant(); void customParserTypes(); void rootAsQmlComponent(); void inlineQmlComponents(); void idProperty(); void autoNotifyConnection(); void assignSignal(); void dynamicProperties(); void dynamicPropertiesNested(); void listProperties(); void dynamicObjectProperties(); void dynamicSignalsAndSlots(); void simpleBindings(); void autoComponentCreation(); void propertyValueSource(); void attachedProperties(); void dynamicObjects(); void customVariantTypes(); void valueTypes(); void cppnamespace(); void aliasProperties(); void componentCompositeType(); void i18n(); void i18n_data(); void onCompleted(); void scriptString(); void defaultPropertyListOrder(); void declaredPropertyValues(); void importsBuiltin_data(); void importsBuiltin(); void importsLocal_data(); void importsLocal(); void importsRemote_data(); void importsRemote(); void importsInstalled_data(); void importsInstalled(); void importsOrder_data(); void importsOrder(); void qmlAttachedPropertiesObjectMethod(); void customOnProperty(); // regression tests for crashes void crash1(); void crash2(); private: QDeclarativeEngine engine; void testType(const QString& qml, const QString& type, const QString& error); }; #define VERIFY_ERRORS(errorfile) \ if (!errorfile) { \ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \ qWarning() << "Unexpected Errors:" << component.errors(); \ QVERIFY(!component.isError()); \ QVERIFY(component.errors().isEmpty()); \ } else { \ QFile file(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(errorfile)); \ QVERIFY(file.open(QIODevice::ReadOnly)); \ QByteArray data = file.readAll(); \ file.close(); \ QList<QByteArray> expected = data.split('\n'); \ expected.removeAll(QByteArray("")); \ QList<QDeclarativeError> errors = component.errors(); \ QList<QByteArray> actual; \ for (int ii = 0; ii < errors.count(); ++ii) { \ const QDeclarativeError &error = errors.at(ii); \ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ QByteArray::number(error.column()) + ":" + \ error.description().toUtf8(); \ actual << errorStr; \ } \ if (qgetenv("DEBUG") != "" && expected != actual) \ qWarning() << "Expected:" << expected << "Actual:" << actual; \ if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\ QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \ QVERIFY(file.open(QIODevice::WriteOnly)); \ for (int ii = 0; ii < actual.count(); ++ii) { \ file.write(actual.at(ii)); file.write("\n"); \ } \ file.close(); \ } else { \ QCOMPARE(expected, actual); \ } \ } inline QUrl TEST_FILE(const QString &filename) { QFileInfo fileInfo(__FILE__); return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename)); } inline QUrl TEST_FILE(const char *filename) { return TEST_FILE(QLatin1String(filename)); } void tst_qdeclarativelanguage::cleanupTestCase() { QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile())); } void tst_qdeclarativelanguage::errors_data() { QTest::addColumn<QString>("file"); QTest::addColumn<QString>("errorFile"); QTest::addColumn<bool>("create"); QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.qml" << "nonexistantProperty.1.errors.txt" << false; QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.qml" << "nonexistantProperty.2.errors.txt" << false; QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.qml" << "nonexistantProperty.3.errors.txt" << false; QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false; QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false; QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false; QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false; QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false; QTest::newRow("wrongType (bad rect)") << "wrongType.3.qml" << "wrongType.3.errors.txt" << false; QTest::newRow("wrongType (invalid enum)") << "wrongType.4.qml" << "wrongType.4.errors.txt" << false; QTest::newRow("wrongType (int for uint)") << "wrongType.5.qml" << "wrongType.5.errors.txt" << false; QTest::newRow("wrongType (string for real)") << "wrongType.6.qml" << "wrongType.6.errors.txt" << false; QTest::newRow("wrongType (int for color)") << "wrongType.7.qml" << "wrongType.7.errors.txt" << false; QTest::newRow("wrongType (int for date)") << "wrongType.8.qml" << "wrongType.8.errors.txt" << false; QTest::newRow("wrongType (int for time)") << "wrongType.9.qml" << "wrongType.9.errors.txt" << false; QTest::newRow("wrongType (int for datetime)") << "wrongType.10.qml" << "wrongType.10.errors.txt" << false; QTest::newRow("wrongType (string for point)") << "wrongType.11.qml" << "wrongType.11.errors.txt" << false; QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false; QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false; QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false; QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false; QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false; QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false; QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false; QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false; QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false; QTest::newRow("invalidID.1") << "invalidID.qml" << "invalidID.errors.txt" << false; QTest::newRow("invalidID.2") << "invalidID.2.qml" << "invalidID.2.errors.txt" << false; QTest::newRow("invalidID.3") << "invalidID.3.qml" << "invalidID.3.errors.txt" << false; QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false; QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false; QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false; QTest::newRow("invalidID.7") << "invalidID.7.qml" << "invalidID.7.errors.txt" << false; QTest::newRow("invalidID.8") << "invalidID.8.qml" << "invalidID.8.errors.txt" << false; QTest::newRow("invalidID.9") << "invalidID.9.qml" << "invalidID.9.errors.txt" << false; QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false; QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true; QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false; QTest::newRow("duplicateIDs") << "duplicateIDs.qml" << "duplicateIDs.errors.txt" << false; QTest::newRow("unregisteredObject") << "unregisteredObject.qml" << "unregisteredObject.errors.txt" << false; QTest::newRow("empty") << "empty.qml" << "empty.errors.txt" << false; QTest::newRow("missingObject") << "missingObject.qml" << "missingObject.errors.txt" << false; QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false; QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false; QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false; QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false; QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false; QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false; QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false; QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false; QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false; QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false; QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true; QTest::newRow("invalidGroupedProperty.8") << "invalidGroupedProperty.8.qml" << "invalidGroupedProperty.8.errors.txt" << false; QTest::newRow("invalidGroupedProperty.9") << "invalidGroupedProperty.9.qml" << "invalidGroupedProperty.9.errors.txt" << false; QTest::newRow("invalidGroupedProperty.10") << "invalidGroupedProperty.10.qml" << "invalidGroupedProperty.10.errors.txt" << false; QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false; QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false; QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false; QTest::newRow("importNonExist (installed)") << "importNonExist.qml" << "importNonExist.errors.txt" << false; QTest::newRow("importNewerVersion (installed)") << "importNewerVersion.qml" << "importNewerVersion.errors.txt" << false; QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false; QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false; QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false; QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false; QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false; QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false; QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false; QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false; QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false; QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false; QTest::newRow("property.5") << "property.5.qml" << "property.5.errors.txt" << false; QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false; QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false; QTest::newRow("importScript.1") << "importscript.1.qml" << "importscript.1.errors.txt" << false; QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false; QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false; QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false; QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false; QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false; QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false; QTest::newRow("MultiSet.1") << "multiSet.1.qml" << "multiSet.1.errors.txt" << false; QTest::newRow("MultiSet.2") << "multiSet.2.qml" << "multiSet.2.errors.txt" << false; QTest::newRow("MultiSet.3") << "multiSet.3.qml" << "multiSet.3.errors.txt" << false; QTest::newRow("MultiSet.4") << "multiSet.4.qml" << "multiSet.4.errors.txt" << false; QTest::newRow("MultiSet.5") << "multiSet.5.qml" << "multiSet.5.errors.txt" << false; QTest::newRow("MultiSet.6") << "multiSet.6.qml" << "multiSet.6.errors.txt" << false; QTest::newRow("MultiSet.7") << "multiSet.7.qml" << "multiSet.7.errors.txt" << false; QTest::newRow("MultiSet.8") << "multiSet.8.qml" << "multiSet.8.errors.txt" << false; QTest::newRow("MultiSet.9") << "multiSet.9.qml" << "multiSet.9.errors.txt" << false; QTest::newRow("MultiSet.10") << "multiSet.10.qml" << "multiSet.10.errors.txt" << false; QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false; QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false; QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false; QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false; QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false; QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false; QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false; QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false; QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false; QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false; QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false; QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false; QTest::newRow("emptySignal.2") << "emptySignal.2.qml" << "emptySignal.2.errors.txt" << false; QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false; QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false; QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false; QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false; QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false; QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false; QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false; } void tst_qdeclarativelanguage::errors() { QFETCH(QString, file); QFETCH(QString, errorFile); QFETCH(bool, create); QDeclarativeComponent component(&engine, TEST_FILE(file)); if(create) { QObject *object = component.create(); QVERIFY(object == 0); } VERIFY_ERRORS(errorFile.toLatin1().constData()); } void tst_qdeclarativelanguage::simpleObject() { QDeclarativeComponent component(&engine, TEST_FILE("simpleObject.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); } void tst_qdeclarativelanguage::simpleContainer() { QDeclarativeComponent component(&engine, TEST_FILE("simpleContainer.qml")); VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); QCOMPARE(container->getChildren()->count(),2); } void tst_qdeclarativelanguage::interfaceProperty() { QDeclarativeComponent component(&engine, TEST_FILE("interfaceProperty.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); QVERIFY(object->interface()); QVERIFY(object->interface()->id == 913); } void tst_qdeclarativelanguage::interfaceQList() { QDeclarativeComponent component(&engine, TEST_FILE("interfaceQList.qml")); VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); QVERIFY(container->getQListInterfaces()->count() == 2); for(int ii = 0; ii < 2; ++ii) QVERIFY(container->getQListInterfaces()->at(ii)->id == 913); } void tst_qdeclarativelanguage::assignObjectToSignal() { QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToSignal.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); emit object->basicSignal(); } void tst_qdeclarativelanguage::assignObjectToVariant() { QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToVariant.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVariant v = object->property("a"); QVERIFY(v.userType() == qMetaTypeId<QObject *>()); } void tst_qdeclarativelanguage::assignLiteralSignalProperty() { QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->onLiteralSignal(), 10); } // Test is an external component can be loaded and assigned (to a qlist) void tst_qdeclarativelanguage::assignQmlComponent() { QDeclarativeComponent component(&engine, TEST_FILE("assignQmlComponent.qml")); VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QVERIFY(object->getChildren()->count() == 1); QObject *child = object->getChildren()->at(0); QCOMPARE(child->property("x"), QVariant(10)); QCOMPARE(child->property("y"), QVariant(11)); } // Test literal assignment to all the basic types void tst_qdeclarativelanguage::assignBasicTypes() { QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2); QCOMPARE(object->stringProperty(), QString("Hello World!")); QCOMPARE(object->uintProperty(), uint(10)); QCOMPARE(object->intProperty(), -19); QCOMPARE((float)object->realProperty(), float(23.2)); QCOMPARE((float)object->doubleProperty(), float(-19.7)); QCOMPARE((float)object->floatProperty(), float(8.5)); QCOMPARE(object->colorProperty(), QColor("red")); QCOMPARE(object->dateProperty(), QDate(1982, 11, 25)); QCOMPARE(object->timeProperty(), QTime(11, 11, 32)); QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1))); QCOMPARE(object->pointProperty(), QPoint(99,13)); QCOMPARE(object->pointFProperty(), QPointF((float)-10.1, (float)12.3)); QCOMPARE(object->sizeProperty(), QSize(99, 13)); QCOMPARE(object->sizeFProperty(), QSizeF((float)0.1, (float)0.2)); QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200)); QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)90.99)); QCOMPARE(object->boolProperty(), true); QCOMPARE(object->variantProperty(), QVariant("Hello World!")); QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml"))); QVERIFY(object->objectProperty() != 0); MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty()); QVERIFY(child != 0); QCOMPARE(child->intProperty(), 8); } // Test edge case type assignments void tst_qdeclarativelanguage::assignTypeExtremes() { QDeclarativeComponent component(&engine, TEST_FILE("assignTypeExtremes.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->uintProperty(), 0xEE6B2800); QCOMPARE(object->intProperty(), -0x77359400); } // Test that a composite type can assign to a property of its base type void tst_qdeclarativelanguage::assignCompositeToType() { QDeclarativeComponent component(&engine, TEST_FILE("assignCompositeToType.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); } // Test that literals are stored correctly in variant properties void tst_qdeclarativelanguage::assignLiteralToVariant() { QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("test1").userType(), (int)QVariant::Int); QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double); QCOMPARE(object->property("test3").userType(), (int)QVariant::String); QCOMPARE(object->property("test4").userType(), (int)QVariant::Color); QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF); QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF); QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF); QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D); QCOMPARE(object->property("test9").userType(), (int)QVariant::String); QVERIFY(object->property("test1") == QVariant(1)); QVERIFY(object->property("test2") == QVariant((double)1.7)); QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!")))); QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800))); QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10))); QVERIFY(object->property("test6") == QVariant(QPointF(10, 10))); QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); delete object; } // Tests that custom parser types can be instantiated void tst_qdeclarativelanguage::customParserTypes() { QDeclarativeComponent component(&engine, TEST_FILE("customParserTypes.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVERIFY(object->property("count") == QVariant(2)); } // Tests that the root item can be a custom component void tst_qdeclarativelanguage::rootAsQmlComponent() { QDeclarativeComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml")); VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->property("x"), QVariant(11)); QCOMPARE(object->getChildren()->count(), 2); } // Tests that components can be specified inline void tst_qdeclarativelanguage::inlineQmlComponents() { QDeclarativeComponent component(&engine, TEST_FILE("inlineQmlComponents.qml")); VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->getChildren()->count(), 1); QDeclarativeComponent *comp = qobject_cast<QDeclarativeComponent *>(object->getChildren()->at(0)); QVERIFY(comp != 0); MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create()); QVERIFY(compObject != 0); QCOMPARE(compObject->value(), 11); } // Tests that types that have an id property have it set void tst_qdeclarativelanguage::idProperty() { QDeclarativeComponent component(&engine, TEST_FILE("idProperty.qml")); VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->getChildren()->count(), 1); MyTypeObject *child = qobject_cast<MyTypeObject *>(object->getChildren()->at(0)); QVERIFY(child != 0); QCOMPARE(child->id(), QString("myObjectId")); QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); } // Tests automatic connection to notify signals if "onBlahChanged" syntax is used // even if the notify signal for "blah" is not called "blahChanged" void tst_qdeclarativelanguage::autoNotifyConnection() { QDeclarativeComponent component(&engine, TEST_FILE("autoNotifyConnection.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify")); QVERIFY(prop.isValid()); QCOMPARE(prop.read(object), QVariant::fromValue(false)); object->setPropertyWithNotify(1); QCOMPARE(prop.read(object), QVariant::fromValue(true)); } // Tests that signals can be assigned to void tst_qdeclarativelanguage::assignSignal() { QDeclarativeComponent component(&engine, TEST_FILE("assignSignal.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); emit object->basicSignal(); QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)"); emit object->basicParameterizedSignal(9); } // Tests the creation and assignment of dynamic properties void tst_qdeclarativelanguage::dynamicProperties() { QDeclarativeComponent component(&engine, TEST_FILE("dynamicProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("intProperty"), QVariant(10)); QCOMPARE(object->property("boolProperty"), QVariant(false)); QCOMPARE(object->property("doubleProperty"), QVariant(-10.1)); QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9)); QCOMPARE(object->property("stringProperty"), QVariant("Hello World!")); QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml"))); QCOMPARE(object->property("colorProperty"), QVariant(QColor("red"))); QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2))); QCOMPARE(object->property("varProperty"), QVariant("Hello World!")); } // Test that nested types can use dynamic properties void tst_qdeclarativelanguage::dynamicPropertiesNested() { QDeclarativeComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("super_a").toInt(), 11); // Overridden QCOMPARE(object->property("super_c").toInt(), 14); // Inherited QCOMPARE(object->property("a").toInt(), 13); // New QCOMPARE(object->property("b").toInt(), 12); // New delete object; } // Tests the creation and assignment to dynamic list properties void tst_qdeclarativelanguage::listProperties() { QDeclarativeComponent component(&engine, TEST_FILE("listProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 2); } // Tests the creation and assignment of dynamic object properties // ### Not complete void tst_qdeclarativelanguage::dynamicObjectProperties() { QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0)); QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0)); } // Tests the declaration of dynamic signals and slots void tst_qdeclarativelanguage::dynamicSignalsAndSlots() { QTest::ignoreMessage(QtDebugMsg, "1921"); QDeclarativeComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1); QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1); QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1); QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1); QCOMPARE(object->property("test").toInt(), 0); QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10))); QCOMPARE(object->property("test").toInt(), 10); } void tst_qdeclarativelanguage::simpleBindings() { QDeclarativeComponent component(&engine, TEST_FILE("simpleBindings.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("value1"), QVariant(10)); QCOMPARE(object->property("value2"), QVariant(10)); QCOMPARE(object->property("value3"), QVariant(21)); QCOMPARE(object->property("value4"), QVariant(10)); QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object)); } void tst_qdeclarativelanguage::autoComponentCreation() { QDeclarativeComponent component(&engine, TEST_FILE("autoComponentCreation.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QVERIFY(object->componentProperty() != 0); MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create()); QVERIFY(child != 0); QCOMPARE(child->realProperty(), qreal(9)); } void tst_qdeclarativelanguage::propertyValueSource() { { QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QList<QObject *> valueSources; QObjectList allChildren = object->findChildren<QObject*>(); foreach (QObject *child, allChildren) { if (qobject_cast<QDeclarativePropertyValueSource *>(child)) valueSources.append(child); } QCOMPARE(valueSources.count(), 1); MyPropertyValueSource *valueSource = qobject_cast<MyPropertyValueSource *>(valueSources.at(0)); QVERIFY(valueSource != 0); QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object)); QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty"))); } { QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.2.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QList<QObject *> valueSources; QObjectList allChildren = object->findChildren<QObject*>(); foreach (QObject *child, allChildren) { if (qobject_cast<QDeclarativePropertyValueSource *>(child)) valueSources.append(child); } QCOMPARE(valueSources.count(), 1); MyPropertyValueSource *valueSource = qobject_cast<MyPropertyValueSource *>(valueSources.at(0)); QVERIFY(valueSource != 0); QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object)); QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty"))); } } void tst_qdeclarativelanguage::attachedProperties() { QDeclarativeComponent component(&engine, TEST_FILE("attachedProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object); QVERIFY(attached != 0); QCOMPARE(attached->property("value"), QVariant(10)); QCOMPARE(attached->property("value2"), QVariant(13)); } // Tests non-static object properties void tst_qdeclarativelanguage::dynamicObjects() { QDeclarativeComponent component(&engine, TEST_FILE("dynamicObject.1.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); } // Tests the registration of custom variant string converters void tst_qdeclarativelanguage::customVariantTypes() { QDeclarativeComponent component(&engine, TEST_FILE("customVariantTypes.qml")); VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); QCOMPARE(object->customType().a, 10); } void tst_qdeclarativelanguage::valueTypes() { QDeclarativeComponent component(&engine, TEST_FILE("valueTypes.qml")); VERIFY_ERRORS(0); QString message = QLatin1String("QML MyTypeObject (") + component.url().toString() + QLatin1String(":2:1) Binding loop detected for property \"rectProperty.width\""); QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); QVERIFY(object != 0); QCOMPARE(object->rectProperty(), QRect(10, 11, 12, 13)); QCOMPARE(object->rectProperty2(), QRect(10, 11, 12, 13)); QCOMPARE(object->intProperty(), 10); object->doAction(); QCOMPARE(object->rectProperty(), QRect(12, 11, 14, 13)); QCOMPARE(object->rectProperty2(), QRect(12, 11, 14, 13)); QCOMPARE(object->intProperty(), 12); // ### #if 0 QDeclarativeProperty p(object, "rectProperty.x"); QCOMPARE(p.read(), QVariant(12)); p.write(13); QCOMPARE(p.read(), QVariant(13)); quint32 r = QDeclarativePropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex()); QDeclarativeProperty p2; QDeclarativePropertyPrivate::restore(p2, r, object); QCOMPARE(p2.read(), QVariant(13)); #endif } void tst_qdeclarativelanguage::cppnamespace() { { QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); delete object; } { QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.2.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); delete object; } } void tst_qdeclarativelanguage::aliasProperties() { // Simple "int" alias { QDeclarativeComponent component(&engine, TEST_FILE("alias.1.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); // Read through alias QCOMPARE(object->property("valueAlias").toInt(), 10); object->setProperty("value", QVariant(13)); QCOMPARE(object->property("valueAlias").toInt(), 13); // Write throught alias object->setProperty("valueAlias", QVariant(19)); QCOMPARE(object->property("valueAlias").toInt(), 19); QCOMPARE(object->property("value").toInt(), 19); delete object; } // Complex object alias { QDeclarativeComponent component(&engine, TEST_FILE("alias.2.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); // Read through alias MyQmlObject *v = qvariant_cast<MyQmlObject *>(object->property("aliasObject")); QVERIFY(v != 0); QCOMPARE(v->value(), 10); // Write through alias MyQmlObject *v2 = new MyQmlObject(); v2->setParent(object); object->setProperty("aliasObject", qVariantFromValue(v2)); MyQmlObject *v3 = qvariant_cast<MyQmlObject *>(object->property("aliasObject")); QVERIFY(v3 != 0); QCOMPARE(v3, v2); delete object; } // Nested aliases { QDeclarativeComponent component(&engine, TEST_FILE("alias.3.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("value").toInt(), 1892); QCOMPARE(object->property("value2").toInt(), 1892); object->setProperty("value", QVariant(1313)); QCOMPARE(object->property("value").toInt(), 1313); QCOMPARE(object->property("value2").toInt(), 1313); object->setProperty("value2", QVariant(8080)); QCOMPARE(object->property("value").toInt(), 8080); QCOMPARE(object->property("value2").toInt(), 8080); delete object; } // Enum aliases { QDeclarativeComponent component(&engine, TEST_FILE("alias.4.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("enumAlias").toInt(), 1); delete object; } // Id aliases { QDeclarativeComponent component(&engine, TEST_FILE("alias.5.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVariant v = object->property("otherAlias"); QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>()); MyQmlObject *o = qvariant_cast<MyQmlObject*>(v); QCOMPARE(o->value(), 10); delete o; v = object->property("otherAlias"); QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>()); o = qvariant_cast<MyQmlObject*>(v); QVERIFY(o == 0); delete object; } // Nested aliases - this used to cause a crash { QDeclarativeComponent component(&engine, TEST_FILE("alias.6.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("a").toInt(), 1923); } // Ptr Alias Cleanup - check that aliases to ptr types return 0 // if the object aliased to is removed { QDeclarativeComponent component(&engine, TEST_FILE("alias.7.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QObject *object1 = qvariant_cast<QObject *>(object->property("object")); QVERIFY(object1 != 0); QObject *object2 = qvariant_cast<QObject *>(object1->property("object")); QVERIFY(object2 != 0); QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject")); QVERIFY(alias == object2); delete object1; QObject *alias2 = object; // "Random" start value int status = -1; void *a[] = { &alias2, 0, &status }; QMetaObject::metacall(object, QMetaObject::ReadProperty, object->metaObject()->indexOfProperty("aliasedObject"), a); QVERIFY(alias2 == 0); } // Simple composite type { QDeclarativeComponent component(&engine, TEST_FILE("alias.8.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("value").toInt(), 10); delete object; } // Complex composite type { QDeclarativeComponent component(&engine, TEST_FILE("alias.9.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("value").toInt(), 10); delete object; } } // Test that the root element in a composite type can be a Component void tst_qdeclarativelanguage::componentCompositeType() { QDeclarativeComponent component(&engine, TEST_FILE("componentCompositeType.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); } class TestType : public QObject { Q_OBJECT public: TestType(QObject *p=0) : QObject(p) {} }; class TestType2 : public QObject { Q_OBJECT public: TestType2(QObject *p=0) : QObject(p) {} }; void tst_qdeclarativelanguage::i18n_data() { QTest::addColumn<QString>("file"); QTest::addColumn<QString>("stringProperty"); QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)"); QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10"); QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15"); QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20"); QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30"); QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40"); } void tst_qdeclarativelanguage::i18n() { QFETCH(QString, file); QFETCH(QString, stringProperty); QDeclarativeComponent component(&engine, TEST_FILE(file)); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->stringProperty(), stringProperty); delete object; } // Check that the Component::onCompleted attached property works void tst_qdeclarativelanguage::onCompleted() { QDeclarativeComponent component(&engine, TEST_FILE("onCompleted.qml")); VERIFY_ERRORS(0); QTest::ignoreMessage(QtDebugMsg, "Completed 6 10"); QTest::ignoreMessage(QtDebugMsg, "Completed 6 10"); QTest::ignoreMessage(QtDebugMsg, "Completed 10 11"); QObject *object = component.create(); QVERIFY(object != 0); } // Check that assignments to QDeclarativeScriptString properties work void tst_qdeclarativelanguage::scriptString() { QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml")); VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); QVERIFY(object != 0); QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object)); QCOMPARE(object->scriptProperty().context(), qmlContext(object)); QVERIFY(object->grouped() != 0); QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object)); QCOMPARE(object->grouped()->script().context(), qmlContext(object)); } // Check that default property assignments are correctly spliced into explicit // property assignments void tst_qdeclarativelanguage::defaultPropertyListOrder() { QDeclarativeComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml")); VERIFY_ERRORS(0); MyContainer *container = qobject_cast<MyContainer *>(component.create()); QVERIFY(container != 0); QCOMPARE(container->getChildren()->count(), 6); QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0)); QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1)); QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2)); QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3)); QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4)); QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5)); } void tst_qdeclarativelanguage::declaredPropertyValues() { QDeclarativeComponent component(&engine, TEST_FILE("declaredPropertyValues.qml")); VERIFY_ERRORS(0); } // Check that first child of qml is of given type. Empty type insists on error. void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror) { QDeclarativeComponent component(&engine); component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports QTRY_VERIFY(!component.isLoading()); if (type.isEmpty()) { QVERIFY(component.isError()); QString actualerror; foreach (const QDeclarativeError e, component.errors()) { if (!actualerror.isEmpty()) actualerror.append("; "); actualerror.append(e.description()); } QCOMPARE(actualerror,expectederror); } else { VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(QString(object->metaObject()->className()), type); } } QML_DECLARE_TYPE(TestType) QML_DECLARE_TYPE(TestType2) // Import tests (QT-558) void tst_qdeclarativelanguage::importsBuiltin_data() { // QT-610 QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); QTest::addColumn<QString>("error"); // import built-ins QTest::newRow("missing import") << "Test {}" << "" << "Test is not a type"; QTest::newRow("not in version 0.0") << "import com.nokia.Test 0.0\n" "Test {}" << "" << "Test is not a type"; QTest::newRow("version not installed") << "import com.nokia.Test 99.0\n" "Test {}" << "" << "module \"com.nokia.Test\" version 99.0 is not installed"; QTest::newRow("in version 0.0") << "import com.nokia.Test 0.0\n" "TestTP {}" << "TestType" << ""; QTest::newRow("qualified in version 0.0") << "import com.nokia.Test 0.0 as T\n" "T.TestTP {}" << "TestType" << ""; QTest::newRow("in version 1.0") << "import com.nokia.Test 1.0\n" "Test {}" << "TestType" << ""; QTest::newRow("qualified wrong") << "import com.nokia.Test 1.0 as T\n" // QT-610 "Test {}" << "" << "Test is not a type"; QTest::newRow("qualified right") << "import com.nokia.Test 1.0 as T\n" "T.Test {}" << "TestType" << ""; QTest::newRow("qualified right but not in version 0.0") << "import com.nokia.Test 0.0 as T\n" "T.Test {}" << "" << "T.Test is not a type"; QTest::newRow("in version 1.1") << "import com.nokia.Test 1.1\n" "Test {}" << "TestType" << ""; QTest::newRow("in version 1.3") << "import com.nokia.Test 1.3\n" "Test {}" << "TestType" << ""; QTest::newRow("in version 1.5") << "import com.nokia.Test 1.5\n" "Test {}" << "TestType" << ""; QTest::newRow("changed in version 1.8") << "import com.nokia.Test 1.8\n" "Test {}" << "TestType2" << ""; QTest::newRow("in version 1.12") << "import com.nokia.Test 1.12\n" "Test {}" << "TestType2" << ""; QTest::newRow("old in version 1.9") << "import com.nokia.Test 1.9\n" "OldTest {}" << "TestType" << ""; QTest::newRow("old in version 1.11") << "import com.nokia.Test 1.11\n" "OldTest {}" << "TestType" << ""; QTest::newRow("multiversion 1") << "import com.nokia.Test 1.11\n" "import com.nokia.Test 1.12\n" "Test {}" << "TestType2" << ""; QTest::newRow("multiversion 2") << "import com.nokia.Test 1.11\n" "import com.nokia.Test 1.12\n" "OldTest {}" << "TestType" << ""; QTest::newRow("qualified multiversion 3") << "import com.nokia.Test 1.0 as T0\n" "import com.nokia.Test 1.8 as T8\n" "T0.Test {}" << "TestType" << ""; QTest::newRow("qualified multiversion 4") << "import com.nokia.Test 1.0 as T0\n" "import com.nokia.Test 1.8 as T8\n" "T8.Test {}" << "TestType2" << ""; } void tst_qdeclarativelanguage::importsBuiltin() { QFETCH(QString, qml); QFETCH(QString, type); QFETCH(QString, error); testType(qml,type,error); } void tst_qdeclarativelanguage::importsLocal_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); QTest::addColumn<QString>("error"); // import locals QTest::newRow("local import") << "import \"subdir\"\n" // QT-613 "Test {}" << "QDeclarativeRectangle" << ""; QTest::newRow("local import second") << "import Qt 4.6\nimport \"subdir\"\n" "Test {}" << "QDeclarativeRectangle" << ""; QTest::newRow("local import subsubdir") << "import Qt 4.6\nimport \"subdir/subsubdir\"\n" "SubTest {}" << "QDeclarativeRectangle" << ""; QTest::newRow("local import QTBUG-7721 A") << "subdir.Test {}" // no longer allowed (QTBUG-7721) << "" << "subdir.Test is not a type"; QTest::newRow("local import QTBUG-7721 B") << "import \"subdir\" as X\n" "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721) << "" << "X.subsubdir.SubTest is not a type"; QTest::newRow("local import as") << "import \"subdir\" as T\n" "T.Test {}" << "QDeclarativeRectangle" << ""; QTest::newRow("wrong local import as") << "import \"subdir\" as T\n" "Test {}" << "" << "Test is not a type"; QTest::newRow("library precedence over local import") << "import \"subdir\"\n" "import com.nokia.Test 1.0\n" "Test {}" << "TestType" << ""; } void tst_qdeclarativelanguage::importsLocal() { QFETCH(QString, qml); QFETCH(QString, type); QFETCH(QString, error); testType(qml,type,error); } void tst_qdeclarativelanguage::importsRemote_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); QTest::addColumn<QString>("error"); QString serverdir = "http://127.0.0.1:14445/qtest/declarative/qmllanguage"; QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QDeclarativeRectangle" << ""; QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QDeclarativeText" << ""; QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QDeclarativeImage" << ""; QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << "" << "WrongTestLocal is not a type"; QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << "" << "LocalInternal is not a type"; QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << "" << "UndeclaredLocal is not a type"; } #include "testhttpserver.h" void tst_qdeclarativelanguage::importsRemote() { QFETCH(QString, qml); QFETCH(QString, type); QFETCH(QString, error); TestHTTPServer server(14445); server.serveDirectory(SRCDIR); testType(qml,type,error); } void tst_qdeclarativelanguage::importsInstalled_data() { // QT-610 QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); QTest::addColumn<QString>("error"); // import installed QTest::newRow("installed import 0") << "import com.nokia.installedtest 0.0\n" "InstalledTestTP {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 0 as TP") << "import com.nokia.installedtest 0.0 as TP\n" "TP.InstalledTestTP {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 1") << "import com.nokia.installedtest 1.0\n" "InstalledTest {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 2") << "import com.nokia.installedtest 1.3\n" "InstalledTest {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 3") << "import com.nokia.installedtest 1.4\n" "InstalledTest {}" << "QDeclarativeText" << ""; QTest::newRow("installed import minor version not available") // QTBUG-9627 << "import com.nokia.installedtest 1.10\n" "InstalledTest {}" << "" << "module \"com.nokia.installedtest\" version 1.10 is not installed"; QTest::newRow("installed import major version not available") // QTBUG-9627 << "import com.nokia.installedtest 9.0\n" "InstalledTest {}" << "" << "module \"com.nokia.installedtest\" version 9.0 is not installed"; QTest::newRow("installed import visibility") // QT-614 << "import com.nokia.installedtest 1.4\n" "PrivateType {}" << "" << "PrivateType is not a type"; } void tst_qdeclarativelanguage::importsInstalled() { QFETCH(QString, qml); QFETCH(QString, type); QFETCH(QString, error); testType(qml,type,error); } void tst_qdeclarativelanguage::importsOrder_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); QTest::addColumn<QString>("error"); QTest::newRow("installed import overrides 1") << "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" << "QDeclarativeText" << ""; QTest::newRow("installed import overrides 2") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "InstalledTest {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import re-overrides 1") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" << "QDeclarativeText" << ""; QTest::newRow("installed import re-overrides 2") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "InstalledTest {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import versus builtin 1") << "import com.nokia.installedtest 1.5\n" "import Qt 4.6\n" "Rectangle {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import versus builtin 2") << "import Qt 4.6\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" << "QDeclarativeText" << ""; QTest::newRow("namespaces cannot be overridden by types 1") << "import Qt 4.6 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" << "" << "Namespace Rectangle cannot be used as a type"; QTest::newRow("namespaces cannot be overridden by types 2") << "import Qt 4.6 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle.Image {}" << "QDeclarativeImage" << ""; QTest::newRow("local last 1") << "LocalLast {}" << "QDeclarativeText" << ""; QTest::newRow("local last 2") << "import com.nokia.installedtest 1.0\n" "LocalLast {}" << "QDeclarativeRectangle" << ""; // i.e. from com.nokia.installedtest, not data/LocalLast.qml } void tst_qdeclarativelanguage::importsOrder() { QFETCH(QString, qml); QFETCH(QString, type); QFETCH(QString, error); testType(qml,type,error); } void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod() { QObject object; QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0); QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0); { QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(object, false), (QObject *)0); QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0); } { QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, false) != 0); QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0); } } void tst_qdeclarativelanguage::crash1() { QDeclarativeComponent component(&engine); component.setData("import Qt 4.6\nComponent {}", QUrl()); } void tst_qdeclarativelanguage::crash2() { QDeclarativeComponent component(&engine, TEST_FILE("crash2.qml")); } // QTBUG-8676 void tst_qdeclarativelanguage::customOnProperty() { QDeclarativeComponent component(&engine, TEST_FILE("customOnProperty.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("on").toInt(), 10); delete object; } void tst_qdeclarativelanguage::initTestCase() { registerTypes(); qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP"); qmlRegisterType<TestType>("com.nokia.Test", 1, 0, "Test"); qmlRegisterType<TestType>("com.nokia.Test", 1, 5, "Test"); qmlRegisterType<TestType2>("com.nokia.Test", 1, 8, "Test"); qmlRegisterType<TestType>("com.nokia.Test", 1, 9, "OldTest"); qmlRegisterType<TestType2>("com.nokia.Test", 1, 12, "Test"); // Create locale-specific file // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile()); QVERIFY(in.open(QIODevice::ReadOnly)); QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()); QVERIFY(out.open(QIODevice::WriteOnly)); out.write(in.readAll()); } QTEST_MAIN(tst_qdeclarativelanguage) #include "tst_qdeclarativelanguage.moc"