04_toolbar_test.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. function loadToolbar(client, fnames) {
  2. for (let name of fnames) {
  3. client.execute(
  4. function (fname) {
  5. _loadToolbar(fname);
  6. }, [name], null
  7. );
  8. let toolbar_name = name.replace(/\//g, "\\2f ").replace(/\./g, "\\2e ");
  9. toolbar_name = "#div_toolbar_" + toolbar_name;
  10. client.waitForElementPresent(toolbar_name, 2000, "Check for toolbar: " + name);
  11. }
  12. }
  13. let user = "./users/testuser/";
  14. let glob = require('glob');
  15. let getFiles = function (client, dir, pattern, failing_files) {
  16. glob(dir + pattern, callback(client, failing_files));
  17. };
  18. function callback(client, failing_files) {
  19. return function (err, res) {
  20. if (err) {
  21. assert(false, "Error in reading directory: " + user + "Toolbars");
  22. } else {
  23. let filenames = [];
  24. for (let i in res) {
  25. let fn = res[i];
  26. fn = "\/" + fn.replace(user, "");
  27. //skip files we know will fail
  28. if (!(failing_files.includes(fn))){
  29. filenames.push(fn);
  30. }
  31. }
  32. //console.log(filenames);
  33. loadToolbar(client, filenames);
  34. }
  35. }
  36. }
  37. module.exports = {
  38. beforeEach: function (client) {
  39. client.url('http://localhost:8124/atompm').pause(300);
  40. },
  41. 'Login': function (client) {
  42. client.execute(
  43. function () {
  44. UserManagement.login('testuser');
  45. }, [], null
  46. );
  47. client.pause(1000);
  48. client.getTitle(function (title) {
  49. this.assert.ok(title.includes("AToMPM - [Unnamed]"), "AToMPM is opened");
  50. });
  51. },
  52. 'Load main menu toolbar': function (client) {
  53. let filename = 'Toolbars/MainMenu/MainMenu.buttons.model';
  54. loadToolbar(client, [filename]);
  55. },
  56. 'Load all metamodels' : function (client) {
  57. let failing_files = ['/Formalisms/__Templates__/ConcreteSyntaxTemplate.defaultIcons.metamodel'];
  58. getFiles(client, user, '/**/*Icons.metamodel', failing_files);
  59. },
  60. // 'Load all pattern metamodels' : function (client) {
  61. // getFiles(client, user, '/**/*Icons.pattern.metamodel');
  62. // // let filename = '\\/Formalisms/__LanguageSyntax__/SimpleClassDiagram/SimpleClassDiagram.defaultIcons.metamodel';
  63. // //loadToolbar(client, [filename]);
  64. //
  65. // },
  66. after: function (client) {
  67. client.end();
  68. },
  69. };