04_toolbar_test.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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, 1000, "Check for toolbar: " + name);
  11. }
  12. }
  13. let user = "./users/testuser/";
  14. let glob = require('glob');
  15. let getFiles = function (client, dir, pattern) {
  16. glob(dir + pattern, callback(client));
  17. };
  18. function callback(client) {
  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. filenames.push("\/" + fn.replace(user, ""));
  27. }
  28. //console.log(filenames);
  29. loadToolbar(client, filenames);
  30. }
  31. }
  32. }
  33. module.exports = {
  34. beforeEach: function (client) {
  35. client.url('http://localhost:8124/atompm').pause(300);
  36. },
  37. 'Login': function (client) {
  38. client.execute(
  39. function () {
  40. UserManagement.login('testuser');
  41. }, [], null
  42. );
  43. client.pause(300);
  44. client.getTitle(function (title) {
  45. this.assert.ok(title.includes("AToMPM - [Unnamed]"), "AToMPM is opened");
  46. });
  47. },
  48. 'Load main menu toolbar': function (client) {
  49. let filename = 'Toolbars/MainMenu/MainMenu.buttons.model';
  50. loadToolbar(client, [filename]);
  51. },
  52. 'Load all toolbars': function (client) {
  53. getFiles(client, user, '/**/*.buttons.model');
  54. },
  55. // 'Load all metamodels' : function (client) {
  56. // getFiles(client, user, '/**/*Icons.metamodel');
  57. // },
  58. // 'Load all pattern metamodels' : function (client) {
  59. // getFiles(client, user, '/**/*Icons.pattern.metamodel');
  60. // // let filename = '\\/Formalisms/__LanguageSyntax__/SimpleClassDiagram/SimpleClassDiagram.defaultIcons.metamodel';
  61. // //loadToolbar(client, [filename]);
  62. //
  63. // },
  64. after: function (client) {
  65. client.end();
  66. },
  67. };